$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 | 目录 |
-e | 存在(也可以用 -a) |
-f | 普通文件 |
-h | 符号连接(也可以用 -L) |
-p | 命名管道 |
-r | 可读 |
-s | 非空 |
-S | 套接字 |
-w | 可写 |
-N | 从上次读取之后已经做过修改 |