shell编程连载【4】- 特殊参数
1 $$:显示PID编号
2 $?:退出状态
【链接】如何查看信号状态?
使用kill -l命令:
[tandesir@localhost ~]$ kill -l
3 $#:显示命令参数的个数
[tandesir@localhost shell]$ vi para_test.sh
[tandesir@localhost shell]$ sh para_test.sh a1 a2
This script was called with 2 arguments.
4 $0:主调程序的名称
[tandesir@localhost shell]$ vi para_test.sh
[tandesir@localhost shell]$ sh para_test.sh
This command used to run this script is para_test.sh.
5 $1~$n:命令行参数
[tandesir@localhost shell]$ vi para_test.sh
[tandesir@localhost shell]$ sh para_test.sh a b c
arg : a b
arg(all) : a b c
6 $*和$@:表示所有命令行参数
[tandesir@localhost shell]$ vi para_test.sh
[tandesir@localhost shell]$ sh para_test.sh a b c
1 parameters with "$*"
1:a b c
2:
3:
[tandesir@localhost shell]$ vi para_test.sh
[tandesir@localhost shell]$ sh para_test.sh a b c
3 parameters with "$@"
1:a
2:b
3:c