变量说明: 
$$ 
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. spring整合freemarker

    一.配置maven <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www ...

  2. #define 小知识

    #define N 15 #define M 2+N #define W 2*M 问3*W的结果是多少? 结果为27: 知识点:define只能进行非常简单的运算,简单来说就是仅仅是将自身的值代入,而 ...

  3. c语言中三个点的解释 : variadic

    3.6 Variadic Macros A macro can be declared to accept a variable number of arguments much as a funct ...

  4. 树莓派 config.txt

    树莓派开机默认配置文件:/boot/config.txt # For more options and information see # http://www.raspberrypi.org/doc ...

  5. 检查项目里是否有IDFA的方法

    检查项目里是否有IDFA的方法: 步骤:1.打开终端cd到要检查的文件的根目录. 2.执行下列语句:grep -r advertisingIdentifier . (别少了最后那个点号). 发现有ma ...

  6. Finereport集群配置

    增加配置文件cluster.xml 将配置包resource文件夹下的cluster.xml打开,如果没有cluster.xml,则新建一个,基本内容如下: <?xml version=&quo ...

  7. iOS中编写单例类的心得

    单例 1.认识过的单例类有哪些: NSUserDefaults.NSNotificationCenter.NSFileManager.UIApplication 2.单例类 单例类某个类在代码编写时使 ...

  8. 十.oc内存管理

    引用百度百科图 栈(stack)又名堆栈. 栈定义:栈是限定仅在表头进行插入和删除操作的线性表(有序).(又称:后进先出表) (动态)数据展示存储的地方.(举例:升降电梯)特点:先进后出(FILO—F ...

  9. oc 单例

    单例模式: //static id _instace; // //+ (id)allocWithZone:(struct _NSZone *)zone //{ // static dispatch_o ...

  10. My97 设置近3天日期

    1.引用my97 js 和css 2.前台代码 <div class="FormItem"> <label> 申请时间</label> < ...