shell内置的特殊变量

$0 :被执行shell文件的路径

[username@hostname]# ./test.sh   则$0 == './test.sh'

$1 , $2, $3 ...., 传递给shell文件的各个参数

[username@hostname]# ./test.sh a b c

则$1=='a', $2=='b', $3=='c'

$# 传递给shell文件的参数个数

./test.sh a b c

扫描二维码关注公众号,回复: 1419264 查看本文章

则$#==3, 可在shell脚本中使用[ $# -gt 0 ] 测试是否传递了参数

猜你喜欢

转载自zhangxugg-163-com.iteye.com/blog/766912