no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | sh [2014/09/26 20:57] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== #!/bin/sh ====== | ||
+ | * [[bash]] | ||
+ | * [[csh]] | ||
+ | * [[ksh]] | ||
+ | * [[tcsh]] | ||
+ | * [[zsh]] | ||
+ | |||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | '' | ||
+ | |||
+ | Use '' | ||
+ | |||
+ | == Shell Symbols == | ||
+ | |||
+ | * **$1..$9** - arguments | ||
+ | * **$0** - process name | ||
+ | * **$#** - number of arguments | ||
+ | * **$?** - exit status | ||
+ | * **$$** - PID of this shell | ||
+ | * **$!** - PID of the last background command | ||
+ | * **$-** - option supplied at shell call (?) | ||
+ | * **$*** - all arguments | ||
+ | * **$@** - all arguments with quotes | ||
+ | |||
+ | == Conditional Statements == | ||
+ | |||
+ | * **-a** and (has higher precedence than -o) | ||
+ | * **-o** or | ||
+ | |||
+ | == String Operators == | ||
+ | |||
+ | * **=** or **==** equal to | ||
+ | * **-n** string is not null | ||
+ | * **-z** string is null, that is, has zero length | ||
+ | |||
+ | == Numeric Operators == | ||
+ | |||
+ | * **-eq** number equals | ||
+ | * **-ne** number does not equal | ||
+ | * **-gt** greater than | ||
+ | * **-ge** greater than or equal to | ||
+ | * **-lt** less than | ||
+ | * **-le** less than or equal to | ||
+ | |||
+ | == File Operators == | ||
+ | |||
+ | * **-e** file exists | ||
+ | * **-f** file is not a directory or device file | ||
+ | * **-d** file exists and is a directory | ||
+ | * **-h** file exists and is a symlink | ||
+ | * **-s** file exists and has a size greater than zero | ||
+ | * **-w** file exists and is writeable | ||
+ | * **-x** file exists and is executable | ||
+ | * **-r** file exists and is readable | ||
+ | * **-b** file is a block device | ||
+ | * **-c** file is a character device | ||
+ | * **-p** file is a pipe | ||
+ | * **-S** file is a socket | ||
+ | * **-O** you are owner of file | ||
+ | * **-G** you are group owner of file | ||
+ | |||
+ | == Built-in commands == | ||
+ | |||
+ | * **:** - null command | ||
+ | * **. file** - execute command in current shell | ||
+ | * **read** - assign //var// from //stdin// | ||
+ | * **readonly** - mark //var// as read only | ||
+ | * **trap** - trap signals | ||
+ | * **type** - inidicate how the shell interprets the command | ||
+ | * **exec** - execute command in place of current shell without creating a new process | ||
+ | * **hash** - rehash command table | ||
+ | |||
+ | == Redirect stderr == | ||
+ | |||
+ | < | ||
+ | echo test 2> /dev/null | ||
+ | </ | ||
+ | |||
+ | == Redirect stderr to stdout == | ||
+ | |||
+ | < | ||
+ | echo test 2>&1 | ||
+ | </ | ||
+ | |||
+ | === String Comparison === | ||
+ | |||
+ | When checking for string length, include the string in quotes. | ||
+ | |||
+ | Both of these will return true: | ||
+ | |||
+ | < | ||
+ | [ -n string ] | ||
+ | [ -n ] | ||
+ | </ | ||
+ | |||
+ | This will return false: | ||
+ | |||
+ | < | ||
+ | [ -n "" | ||
+ | </ |