shell 特殊字符的含义

1.        $?: 上一命令的返回值

2.        $$: 当前进程的进程号

3.        $!: 最后一个后台运行的进程的ID号

4.        $#: 参数的个数(不包含argv[0])

5.        $*: ???以一个单字符串显示所有的脚本传递的参数。 Expands to the positional parameters, starting from one.  When the expansion occurs within doublequotes, it expands to a single word with the value of each parameter separatedby the first character of the IFS special variable.   That is, “$*” is equivalent to "$1c$2c...”,where c is the first character of the value of the IFS variable.  If IFS is unset, the parameters are separatedby spaces. If IFS is null, the parameters are joined without interveningseparators.

6.        $@: 列出所有的参数,各参数用空格隔开。Expands to the positional parameters, starting from one.  When the expansion occurs within doublequotes, each parameter expands to a separate word.   That is, "$@" is equivalent to"$1" "$2" ...  If thedouble-quoted expansion occurs within a word, the expansion of the firstparameter is joined with the beginning part of the original word, and theexpansion of the last parameter is joined with the last part of the originalword.  When there are no positionalparameters, "$@" and $@ expand to nothing (i.e., they are removed).${@:x}, x is the started of the paraters, example, if x==2, then start from $2.

7.        $0: 脚本名称(argv[0])

8.        $1, $2, $3: 取参数(命令行参数,或函数参数)



猜你喜欢

转载自blog.csdn.net/lcxhjg/article/details/80938861