Basic Syntax and Special Characters
| Character | Description |
|---|---|
| # | comment, shebang, # |
| \ | nextline, escapecode |
| ; | used to interpret what follows as a new command to be executed |
| $ | environment variable |
| > | redirect output |
| » | Append output |
| < | Redirect input |
| | | pipe the result into next command |
Putting Multiple Commands on a Single Line
# run consequent command whether or not preceding one succeeded.
$ make ; make install ; make clean
# proceed next command only when preceding one succeeded.
$ make && make install && make clean
# if cat is succeed, then stop executing any further steps.
$ cat file1 || cat file2 || cat file3
Script Parameters
| Parameter | Meaning |
|---|---|
| $0 | script name |
| $1, $2.. | second, third parameter |
| $* | all parameter |
| $# | number of arguments |
Command Substitution
$()
Exporting Environment Variables
export with no arguments will give a list of all currently exported environment variables.
Function
showmess() {
echo My favorite Linux Distribution is: $1
}
showmess Ubuntu