| & | Run the previous command in the background | ls & |
|---|
| && | Logical AND | if [ "$X" -ge "0" ] && [ "$X" -le "9"] |
|---|
| || | Logical OR | if [ "$X" -lt "0" ] || [ "$X" -gt "9" ] |
|---|
| ^ | Start of line | grep "^X" |
|---|
| $ | End of line | grep "X$" |
|---|
| = | String equality (cf. -eq) | if [ "$X" = "bar" ] |
|---|
| ! | Logical NOT | if [ "$X" != "bar" ] |
|---|
| $$ | PID (Process ID)of current shell | echo "my PID = $$" |
|---|
| $! | PID of last background command | ls & echo "PID of ls = $!" |
|---|
| $? | exit status of last command | ls ; echo "ls returned code $?" |
|---|
| $0 | Name of current command (as called) | echo "I am $0" |
|---|
| $1 | Name of current command’s first parameter | echo "The first argument is $1" |
|---|
| $9 | Name of current command’s ninth parameter | echo "The ninth argument is $9" |
|---|
| $@ | All of current command’s parameters (preserving whitespace and quoting) | echo "The arguments are $@" |
|---|
| $* | All of current command’s parameters (not preserving whitespace and quoting) | echo "The arguments are $*" |
|---|
| -eq | Numeric Equality | if [ "$X" -eq "9" ] |
|---|
| -ne | Numeric Inquality | if [ "$X" -ne "9" ] |
|---|
| -lt | Less Than | if [ "$X" -lt "9" ] |
|---|
| -le | Less Than or Equal | if [ "$X" -le "9" ] |
|---|
| -gt | Greater Than | if [ "$X" -gt "9" ] |
|---|
| -ge | Greater Than or Equal | if [ "$X" -ge "9" ] |
|---|
| -z | String is zero length | if [ -z "$X" ] |
|---|
| -n | String is not zero length | if [ -n "$X" ] |
|---|
| -nt | Newer Than | if [ "$file1" -nt "$file2" ] |
|---|
-ot | Older Than | if [ “$file1” -ot “$file2” ] |
| -d | Is a Directory | if [ -d /bin ] |
|---|
| -f | Is a File | if [ -f /bin/ls ] |
|---|
| -r | Is a readable file | if [ -r /bin/ls ] |
|---|
| -w | Is a writable file | if [ -w /bin/ls ] |
|---|
| -x | Is an executable file | if [ -x /bin/ls ] |
|---|
-a, -e | file exists | |
| -ef | Paths refer to the same file | |
| -O | File is owned by the user running the test | |
| -S | Denotes Socket File | |
| ( … ) | Function definition | function thefunc() { echo hello world } |
|---|
Suggestions