Linux 中 shell 变量 $#,$@,$0,$1,$2 的含义解释:
来源:互联网 发布:php artisan db seed 编辑:程序博客网 时间:2024/06/16 12:13
变量说明:
$$ 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 QQThe complete list is 24249The complete list isThe complete list is 0The complete list is 123456 QQThe complete list is 123456The complete list is QQThe complete list is 2The complete list is params.shThe complete list is 123456The complete list is QQ
更多解释见下面文档
下载地址:http://www.tldp.org/LDP/abs/abs-guide.pdf
0 0
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释:
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释:
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- linux中shell变量$#,$@,$0,$1,$2的含义解释
- 【Unity3D】笔记之OnGUI()下的自适屏
- 代码添加constraint,设置translatesAutoresizingMaskIntoConstraints为NO的原因
- HDU 1495 非常可乐
- 数据对齐 posix_memalign 函数详解
- 数据结构与算法学习笔记(一)最大公约数与最小公倍数
- Linux 中 shell 变量 $#,$@,$0,$1,$2 的含义解释:
- Android三种实现定时器的方法
- 深入理解JavaScript闭包
- 编译器常识
- android的自定义listview以及listview常用属性设置
- 关于sql乱码的解决办法总结
- ARIMA(p,d,q)模型-1-MA模型
- Maven搭建SpringMVC+Hibernate项目详解
- !HDU 1074 Doing Homework--DP--(状态压缩)