Linux 于 shell 变数 $#,$@,$0,$1,$2 含义解释:
2015-09-20 19:47
393 查看
变量说明:
演示样例:
结果:
很多其它解释见以下文档
下载地址:http://www.tldp.org/LDP/abs/abs-guide.pdf
$$ Shell自己PID(ProcessID) $! Shell背景上次执行Process的PID $? 命令的结束代码(返回值) $- 使用Set命令设定的Flag一览 $* 全部參数列表。如"$*"用「"」括起来的情况、以"$1 $2 … $n"的形式输出全部參数。 $@ 全部參数列表。如"$@"用「"」括起来的情况、以"$1" "$2" … "$n" 的形式输出全部參数。 $# 加入到Shell的參数个数 $0 Shell本身的文件名称 $1~$n 加入到Shell的各參数值。$1是第1參数、$2是第2參数…。
演示样例:
#!/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"
结果:
[Aric@localhost ~]$ bash params.sh 123456 QQ The complete list is 24249 The complete list is The complete list is 0 The complete list is 123456 QQ The complete list is 123456 The complete list is QQ The complete list is 2 The complete list is params.sh The complete list is 123456 The complete list is QQ
很多其它解释见以下文档
下载地址:http://www.tldp.org/LDP/abs/abs-guide.pdf
相关文章推荐
- shell总结
- shell快捷键
- How to install and configure Azure PowerShell
- Shell编程入门(再版)(在)
- Shell 进制转换
- Linux Shell之sort命令(转)
- HBase Shell
- shell基础(三):让文本飞一会~
- shell脚本报错换行符syntax error near unexpected token \r
- Windows常用shell命令
- shell 脚本学习笔记-1 终端打印 变量 环境变量
- shell的详细介绍和编程(上)
- bash编程:条件测试
- bash编程 :if,case语句
- Python Shell 值的传送
- Linux shell的条件判断、循环语句及实例
- Linux shell的条件判断、循环语句及实例
- bash编程 :循环语句
- shell脚本基础进阶(二)----变量及运算符
- Linux Shell