码迷,mamicode.com
首页 > 系统相关 > 详细

linux中shell变量$#,$@,$0,$1,$2的含义

时间:2015-07-27 14:54:26      阅读:143      评论:0      收藏:0      [点我收藏+]

标签:

printf "The complete list is %s\n" "$$" 24520 Shell本身的PID
printf "The complete list is %s\n" "$!" 空 Shell最后运行的后台Process的PID
printf "The complete list is %s\n" "$?" 0 最后运行的命令的结束代码(返回值)
printf "The complete list is %s\n" "$*" 123 qq 所有参数列表。如"$*"用「"」括起来的情况、以"$1 $2 … $n"的形式输出所有参数。
printf "The complete list is %s\n" "$@" 123

printf "The complete list is %s\n" "$@" 1 qq 所有参数列表。如"$@"用「"」括起来的情况、以"$1" "$2" … "$n" 的形式输出所有参数


printf "The complete list is %s\n" "$#" 2 添加到Shell的参数个数
printf "The complete list is %s\n" "$0" 1.sh Shell本身的文件名
printf "The complete list is %s\n" "$1" 123 添加到Shell的各参数值。$1是第1参数、$2是第2参数…
printf "The complete list is %s\n" "$2" qq


$@ 里是一个列表
$* 是整体一行字串。

linux中shell变量$#,$@,$0,$1,$2的含义

标签:

原文地址:http://www.cnblogs.com/newqzp/p/4679979.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!