Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using Linux Commands Lab 4 1. Create empty files To create an empty file $ touch apple banana grape grapefruit watermelon $ ls -l Using file-matching.

Similar presentations


Presentation on theme: "Using Linux Commands Lab 4 1. Create empty files To create an empty file $ touch apple banana grape grapefruit watermelon $ ls -l Using file-matching."— Presentation transcript:

1 Using Linux Commands Lab 4 1

2 Create empty files To create an empty file $ touch apple banana grape grapefruit watermelon $ ls -l Using file-matching metacharacters Metacharacters help to match one or more files without typing each filename completely.  *This matches any number of characters.  ?This matches any one character.  […]This matches any one of the characters between the brackets, which can include a dash-separated rang of letters or numbers. 2

3 $ ls a* apple $ ls g* grape grapefruit $ ls g*t grapefruit $ ls *e* apple grape grapefruit watermelon $ ls *n* banana watermelon Using file-matching metacharacters Using file-matching metacharacters This matches any number of characters * 3

4 Using file-matching metacharacters Using file-matching metacharacters This matches any one character? $ ls ????e Apple grape $ ls g???e* grape grapefruit 4

5 Using file-matching metacharacters Using file-matching metacharacters This matches any one of the characters between the brackets […] $ ls [abw]* apple banana watermelon $ ls [agw] * [ne] grape grapefruit $ ls [a-g] * apple banana grape grapefruit 5

6 Using file-redirection metacharacters $ mail root < ~/.bashrc $ echo “I finished the project on $(date)” > ~/projects Direct the contents of a file to the command < overwriting Direct the output of a command to a file, overwriting any existing file > adding Direct the output of a command to a file, adding the output to the end of existing file >> $ echo “I finished the project on $(date)” >> ~/projects 6

7 date commands Change or set current date and time. Syntax date [date or time string ] Examples Show current date & time Set date to 2011-Mar-15 Set date as well as time $ date $date --date=“2011-3-15 $date --date=“2001-3-15 11:59 AM” 7

8 echo Command Use echo command to display text or value of variable. echo [options] [string, variables...] Displays text or variables value on screen. 8

9 echo Command Options -n Do not output the trailing new line. -e Enable interpretation of the following backslash escaped characters in the strings: \a alert (bell) \b backspace \n new line \t horizontal tab 9

10 Quotes "Double Quotes" - Anything enclose in double quotes removed meaning of that characters (except \ and $). 'Single quotes' - Enclosed in single quotes remains unchanged. `Back quote` - To execute command 10

11 Examples of quoting special characters $ echo ' My working directory is `pwd`' My working directory is`pwd` $ echo "My working directory is `pwd`” My working directory is /home/jane $ echo -e "An apple a day keeps away \a\t\tdoctor\n" 11

12 Sort command Piping command sort {file-name} Options -r Reverse normal order (so "Z" starts the list instead of "A"). -n Sort in numeric order -nr Sort in reverse numeric order $ ls /etc/password | sort | less 12

13 Sequential commands To run a sequence of commands type several commands on the same command line and separating them with semicolons(;) $ mkdir ng ; cd ng ; touch tom 13


Download ppt "Using Linux Commands Lab 4 1. Create empty files To create an empty file $ touch apple banana grape grapefruit watermelon $ ls -l Using file-matching."

Similar presentations


Ads by Google