变量说明: 
$$ 
Shell本身的PID(ProcessID) 
$! 
Shell最后运行的后台Process的PID 
$? 
最后运行的命令的结束代码(返回值) 
$- 
使用Set命令设定的Flag一览 
$* 
所有参数列表。如"$*"用「"」括起来的情况、以"$1 $2 … $n"的形式输出所有参数。 
$@ 
所有参数列表。如"$@"用「"」括起来的情况、以"$1" "$2" … "$n" 的形式输出所有参数。 
$# 
添加到Shell的参数个数 
$0 
Shell本身的文件名 
$1~$n 
添加到Shell的各参数值。$1是第1参数、$2是第2参数…。 

示例:

1 #!/bin/bash
 2 #
 3 printf "The complete list is %s\n" "$$"
 4 printf "The complete list is %s\n" "$!"
 5 printf "The complete list is %s\n" "$?"
 6 printf "The complete list is %s\n" "$*"
 7 printf "The complete list is %s\n" "$@"
 8 printf "The complete list is %s\n" "$#"
 9 printf "The complete list is %s\n" "$0"
10 printf "The complete list is %s\n" "$1"
11 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
Have a nice day!!!

随机推荐

  1. 微软要支持Objective-C了

    今天的新闻,见http://www.solidot.org/story?sid=43899 更详细的见,http://arstechnica.com/information-technology/20 ...

  2. 在table中进行内容搜索

    $("tbody td").filter(":contains('" + x + "')").css('color','red').pare ...

  3. Tomcat 设置

    bin/catalina.bat--增加内存 set JAVA_OPTS=...后面加上 set JAVA_OPTS=-Xmx1024M -Xms512M -XX:MaxPermSize=256m c ...

  4. LAMP之准备,samba搭建

    搭建lamp其实并没有多复杂,只是,最多的时间是花在下载等待和计算机编译等上面耗时,要是时间多花在这些事情上面总感觉有点亏.经过我多次实践,发现在linux下使用下载会有诸多问题,甚至不如window ...

  5. modelsim 中 WAVE窗口中能不能只显示变量名,而不显示路径

    可以的,在wave窗口左下角有一个黑色的logo,你点击它就可以省电路径,只显示port名称,再点击就切换回来了,如图红色圈圈标记的logo,你可以试试!

  6. 从H264码流中获取视频宽高 (SPS帧)

    获取.h264视频宽高的方法 花了2个通宵终于搞定.(后面附上完整代码) http://write.blog.csdn.net/postedit/7852406 图像的高和宽在H264的SPS帧中.在 ...

  7. 关于 cellForRor中给cell setSelected的时机问题?

    我在  cell  里边 - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selecte ...

  8. 轻型的ORM类Dapper

    Dapper是一个轻型的ORM类.代码就一个SqlMapper.cs文件,主要是IDbConnection的扩展方法,编译后就40K的一个很小的dll.官方站点http://code.google.c ...

  9. 第二章 centos安装maven

    一.官网下载 apache-maven-3.3.9-bin.tar.gz 注意:需要jdk1.7及以上 二.上传 scp apache-maven-3.3.9-bin.tar.gz root@10.2 ...

  10. NGUI 使用EventDelegate.Add与UIInput.onSubmit、UIInput.onChange限定编辑框中的内容

    Unity中,使用NGUI,通常为某个控件(如按钮)绑定事件(单击.双击.拖拽.滚轮.选择等)都是用UIEventListener,比如: public void Bind() { UIEventLi ...