对于脚本而言:
$1 - $9分别是第一到第9个参数
$0 是该脚本的名字,具体来说是运行名,比如一个叫做1的脚本,$0就是./1
$(10)及之后的要用括号括起来
$#表示参数的个数
$*是列出所有的参数
如下表所示:
Positional Parameter | What It References |
---|---|
$0 | References the name of the script |
$# | Holds the value of the number of positional parameters |
$* | Lists all of the positional parameters |
$@ | Means the same as $*, except when enclosed in double quotes |
"$*" | Expands to a single argument (e.g., "$1 $2 $3") |
"$@" | Expands to separate arguments (e.g., "$1" "$2" "$3") |
$1 ... ${10} | References individual positional parameters |
对于命令而言,$0根据不同命令不同。比如exec后面的参数$0是执行命令的绝对路径。