Pages

Sunday, February 12, 2012

Linux Beginner Part-2 (Special Characters)


Special Characters
Before we continue to learn about Linux shell commands, it is important to know that there are
many symbols and characters that the shell interprets in special ways.


Character Description

/     Directory separator, used to separate a string of directory names.
Example: /usr/src/linux

.    Current directory.  Can also “hide” files when it is the first character in a filename.

..   Parent directory

~   User's home directory

*   Represents 0 or more characters in a filename, or by itself, all files in a directory.
Example: pic*2002 can represent the files pic2002, picJanuary2002, 
picFeb292002, etc.

?   Represents a single character in a filename.
Example: hello?.txt can represent hello1.txt, helloz.txt, but not 
hello22.txt 

|   “Pipe”.  Redirect the output of one command into another command.
Example: ls | more 

>   Redirect output of a command into a new file.  If the file already exists, over-write it.
Example: ls > myfiles.txt 

>>  Redirect the output of a command onto the end of an existing file.
Example: echo “Mary 555-1234” >> phonenumbers.txt 

<   Redirect a file as input to a program.
Example: more < phonenumbers.txt 

;   Command separator.  Allows you to execute multiple commands on a single line.
Example: cd /var/log ; less messages

&&  Command separator as above, but only runs the second command if the first one
finished without errors.
Example: cd /var/logs && less messages 


&   Execute a command in the background, and immediately get your shell back.
Example: find / -name core > /tmp/corefiles.txt & 

No comments:

Post a Comment