Linux Batch

$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. 一些常见的文件测试

操作符特征
-ddirectory
-eexisting(same as -a)
-ffile
-hlink sympol(也可以用 -L)
-ppipe
-ris readable
-snot null
-Ssocket
-wwritable
-Nis modified since last read