2016-07-12 10:34 by pursuer.chen, 111 阅读, 0 评论, 收藏, 编辑
介绍
正文
$?
?是shell变量,表示"最后一次执行命令"的退出状态.0为成功,非0为失败.切记:?永远表示shell命令最后一次执行后的退出状态,当函数执行完毕后,如果又执行了其它命令,则$?不再表示函数执行后的状态,而表示其它命令的退出状态
$$ Shell本身的PID(ProcessID) $! Shell最后运行的后台Process的PID $? 最后运行的命令的结束代码(返回值) $- 使用Set命令设定的Flag一览 $* 所有参数列表。如"$*":以"$1 $2 … $n"的形式输出所有参数。 $@ 所有参数列表。如"$@":以多行的形式"$1" "$2" … "$n" 输出所有参数。 $# 添加到Shell的参数个数 $0 Shell本身的文件名 $1~$n 添加到Shell的各参数值。$1是第1参数、$2是第2参数…。
例:
vim a.sh
#!/bin/bash printf "The complete list is %s\n" "$$" printf "The complete list is %s\n" "$!" printf "The complete list is %s\n" "$?" printf "The complete list is %s\n" "$*" printf "The complete list is %s\n" "$@" printf "The complete list is %s\n" "$#" printf "The complete list is %s\n" "$0" printf "The complete list is %s\n" "$1" printf "The complete list is %s\n" "$2"
总结
本文转自pursuer.chen(陈敏华)博客园博客,原文链接:http://www.cnblogs.com/chenmh/p/5383542.html,如需转载请自行联系原作者