Command line, special symbols

Some symbols used in command line :
” “ double quotes – double quotes allow variable expansion
‘ ‘ single quotes – anything within single quotes is interpreted literally, single quotes completely protect a string from the shell (script)
` ` backticks – Text within backticks is treated as a separate command whose results are substituted on the command line.
& ampersand – tells the shell to go on to the next line without waiting for the first to finish.
\ escape – If you want to match one of the special characters, such as a dot, you must escape it—that is, precede it with a backslash (\)
$? – holds the exit status of the last executed command
~ – refers to user`s home directory

Redirectors :
> Creates a new file containing standard output. If the specified file exists, it’s overwritten.
>> Appends standard output to the existing file. If the specified file doesn’t exist, it’s created.
2> Creates a new file containing standard error. If the specified file exists, it’s overwritten.
2>> Appends standard error to the existing file. If the specified file doesn’t exist, it’s created.
&> Creates a new file containing both standard output and standard error. If the specified file exists, it’s overwritten.
< Sends the contents of the specified file to be used as standard input.
<< Accepts text on the following lines as standard input.
<> Causes the specified file to be used for both standard input and standard output.

xargs builds a command from its standard input
| – pipe – the standard output from one program is redirected as the standard input to a second program

Conditional expressions (in scripts) :
&& – logical AND
|| – logical OR
if+then+else+fi – IF
case+esac – to list several commands
while+do+done – loop that runs as long as the condition is true
until+do+done – loop that runs as long as the condition is false
for+do+done – loop

Variables that are passed to the script are frequently called parameters or arguments. They’re represented in the script by a dollar sign ($) followed by a number from 0 up—$0 stands for the name of the script, $1 is the first parameter to the script, $2 is the second parameter, and so on.

This entry was posted in Linux and tagged , . Bookmark the permalink.

Comments are closed.