$0 is the name of the script itself, $1 is the first argument, $2 the second, $3 the third, and so forth.
[27] After $9, the arguments must be enclosed in brackets, for example, ${10}, ${11}, ${12}.
The special variables $* and $@ denote all the positional parameters.
The shift command reassigns the positional parameters, in effect shifting them to the left one notch.
$1 <--- $2, $2 <--- $3, $3 <--- $4, etc.
表 1. 一些常见的文件测试
| 操作符 | 特征 |
|---|---|
| -d | directory |
| -e | existing(same as -a) |
| -f | file |
| -h | link sympol(也可以用 -L) |
| -p | pipe |
| -r | is readable |
| -s | not null |
| -S | socket |
| -w | writable |
| -N | is modified since last read |