首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 操作系统 >

shell 非一般变量

2012-06-28 
shell 特殊变量[linest@036194.sqa.cm4]$ sh test.sh a b c d e$0 return shell nametest.sh$n return nth

shell 特殊变量
[linest@036194.sqa.cm4]$ sh test.sh a b c d e
$0 return shell name
test.sh
$n return nth parameter
c
$* return all parameters
a b c d e
$# return the number of parameters
5
$$ return current shell pid
32202
$! return last command pid
32203
$? return last command return value(0 success other fail)
0
$@ return all the parameters
a b c d e
$@ treat each parameter individually  $* treat all parameters as a whole string
[linest@036194.sqa.cm4]$


$0 返回脚本名称,但如果运行时含路径,也显示路径信息
${0%/*}可以获得脚本所在的目录
不同于pwd获得运行目录

热点排行