变量
| 描述 | |
|---|---|
| $0 | The filename of the current script. |
| $n | These variables correspond to the arguments with which a script was invoked. Here n is a positive decimal number corresponding to the position of an argument (the first argument is $1, the second argument is $2, and so on). |
| $# | The number of arguments supplied to a script. |
| $* | All the arguments are double quoted. If a script receives two arguments, $* is equivalent to $1 $2. |
| $@ | All the arguments are individually double quoted. If a script receives two arguments, $@ is equivalent to $1 $2. |
| $? | The exit status of the last command executed. |
| $$ | The process number of the current shell. For shell scripts, this is the process ID under which they are executing. |
| $! | The process number of the last background command. |
本文详细介绍了Shell脚本中常用的各种特殊变量,包括当前脚本文件名、传递给脚本的参数、参数数量、所有参数的双引号形式、单独引用参数、上一个命令的退出状态、当前shell进程号及最后一个后台命令的进程号。

1137

被折叠的 条评论
为什么被折叠?



