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: 取参数(命令行参数,或函数参数)



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值