变量说明:

$$        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

版权声明:本文博主原创文章。博客,未经同意不得转载。

随机推荐

  1. Redis 安装与简单示例(转)

    本文转载自:http://www.cnblogs.com/kissdodog/p/3570984.html Redis的安装 Redis下载地址如下:https://github.com/dmajki ...

  2. 关于Opencv2.4.x中stitcher类的简单应用

    1.opencv2.4以上版本有stitcher类,可以简单方便的实现图像的拼接,目前只是简单的测试一下stitcher类的拼接功能,也是纠结了好长时间,最终发现是要在链接库中加上opencv_sti ...

  3. hadoop学习;大数据集在HDFS中存为单个文件;安装linux下eclipse出错解决;查看.class文件插件

    sudo apt-get install eclipse 安装后打开eclipse,提示出错 An error has occurred. See the log file /home/pengeor ...

  4. 通过Java字节码发现有趣的内幕之String篇(上)(转)

    原文出处: jaffa 很多时候我们在编写Java代码时,判断和猜测代码问题时主要是通过运行结果来得到答案,本博文主要是想通过Java字节码的方式来进一步求证我们已知的东西.这里没有对Java字节码知 ...

  5. NSUserDefaults写作和阅读对象定义自己

    需要编写对象必须实现NSCoding protocol Person Class Person.h #import <Foundation/Foundation.h> #import &q ...

  6. UVA 1513 - Movie collection(树状数组)

    UVA 1513 - Movie collection option=com_onlinejudge&Itemid=8&page=show_problem&category=5 ...

  7. 垂死或涅槃重生 -- Delphi XE5 我们将宣布感情的回归

    Delphi 在很大程度上是一个被遗忘我的工具. 无论是在使用RapidSql , 我还没有收到Embarcadero 本公司发行参与邀请Delphi XE5该公告将. 可能有人会问,为什么Embar ...

  8. Node.js : 我只需要一个店小二

    刚刚开始接触Node.js时, google了很多文章,但发现大部分都是泛泛的介绍安装,配置,以及介绍几个小例子 有一种雾里观花的感觉,所以非常困惑,不知道Node.js到底解决了什么问题,它的优势到 ...

  9. 【ThinkingInC++】8、说明,浅谈数据类型的大小

    /** * 特征:说明.浅谈数据类型的大小 * 时刻:2014年8一个月10日本11:02:02 * 笔者:cutter_point */ #include<iostream> using ...

  10. 【HTML+CSS】(1)基本语法

    HTML基金会 <em>他强调标签,<strong>加粗标签 <q>短文本引用.<blockquote>长文本引用,这两个标签会让文字带双引號.   空 ...