Shell特殊变量大全: $0, $#, $*, $@, $?, $$,$!,$- 简介.$@ $*对比详解 -- shell学习 逃离我推掉我的手 2022-06-10 06:57 168阅读 0赞 # Shell特殊变量 # ### $0 \---------- 当前脚本的文件名(不带路经,带扩展名 .sh )xx.sh ### ### $n \---------- 返回第n个参数。( n>0 ) ### ### $\# \---------- 统计传入的变量个数 e.g. ./xx.sh p1 p2 输出2 ### ### $\* ---------- 列出所有参数 。" $\* " 整体列出 ### ### $@\---------- 列出所有参数 。"$@" 一一列出 ### ### $?\---------- 返回上一个命令执行的返回码 ### ### $$\---------- 返回pid ### ### $! --------- 最后运行的后台Process的pid ### ### $- \--------- 列出Set命令设定的Flag ### > 测试:具体内容见源码github:[https://github.com/timo1160139211/shellCoding/blob/master/variable.sh][https_github.com_timo1160139211_shellCoding_blob_master_variable.sh] > > > ![Center][] > > 源码 : > [https://github.com/timo1160139211/shellCoding/blob/master/variable.sh][https_github.com_timo1160139211_shellCoding_blob_master_variable.sh] > 参考资料: > [Shell教程][Shell] http://c.biancheng.net/cpp/view/2739.html > > <Linux命令行与shell脚本编程大全(第二版)> 人民邮电出版社 ISBN-9787115288899 > > <Advanced Bash-Scripting Guide> http://www.tldp.org/LDP/abs/abs-guide.pdf > > > > > > [https_github.com_timo1160139211_shellCoding_blob_master_variable.sh]: https://github.com/timo1160139211/shellCoding/blob/master/variable.sh [Center]: /images/20220610/85953a0a40904baea19c7abfee450297.png [Shell]: http://c.biancheng.net/cpp/shell/
还没有评论,来说两句吧...