变量说明: 
$$ 
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. ngx.lua中遇到的小问题2

    用lua+drizzle在数据库中插入数据失败(不能访问数据库) 后面发现原来是nginx配置文件中的drizzle模块部分最后多了一行  content_by_lua 'ngx.say(" ...

  2. python install_opener用法

    opener:当你获取一个URL时,你使用一个opener(OpenerDirector).正常情况下我们一直使用默认的opener,通过urlopen,但你也可以创建自定义的openers. url ...

  3. DirectX12 Samples 学习笔记 – PredicationQueries

    一.效果 这是一个比较简单的sample,运行sample可以看到,当红橙色长方形完全覆盖白色正方形时,白色正方形不显示,其他情况,均显示白色正方形. 二.实现 Render主要由三个部分组成 1.F ...

  4. JavaScript学习(一)—处理事件

    一.处理事件(一) 事件(event)是用户在访问页面时执行的操作.提交表单和在图像上移动鼠标就是两种事件.当浏览器探测到一个事件时,比如用鼠标单击或按键,它可以触发与这个事件相关联的JavaScri ...

  5. 九宝老师微信小程序开发的过程

  6. 自定义shape文件

    1.shape文件 btn_bg.xml文件内容 <?xml version="1.0" encoding="utf-8"?> <shape ...

  7. modelsim仿真vivado自动化脚本

    quit -sim set PATH1 C:/modeltech64_10.2c/xilinx144_lib set PATH2 C:/xilinx1/Vivado/2014.4/data/veril ...

  8. SonarQube-5.6.3 代码分析平台搭建使用

    python代码分析 官网主页: http://docs.sonarqube.org/display/PLUG/Python+Plugin Windows下安装使用: 快速使用: 1.下载jdk ht ...

  9. FastDFS.Client操作文件服务器

    1.配置文件设置 <configSections> <section name="fastdfs" type="FastDFS.Client.Confi ...

  10. java javacv调用摄像头并拍照

    调用摄像头并拍张照片,我一开始用的java的jmf媒体框架,但这个有很多的局限性不好使并且很有麻烦,兜了一圈发现javacv东西,研究之后这东西简单,方便:废话不多说了来重点. javacv官网:点击 ...