$0 这个程式的执行名字
$n 这个程式的第n个参数值,n=1..9
$* 这个程式的所有参数,此选项参数可超过9个。
$# 这个程式的参数个数
$$ 这个程式的PID(脚本运行的当前进程ID号)
$! 执行上一个背景指令的PID(后台运行的最后一个进程的进程ID号)
$? 执行上一个指令的返回值 (显示最后命令的退出状态。0表示没有错误,其他任何值表明有错误)
$- 显示shell使用的当前选项,与set命令功能相同
$@ 跟$*类似,但是可以当作数组用

示例:

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
 

随机推荐

  1. javaee学习之servlet

    一.tomcat相关知识 tomecat虚拟主机与虚拟路径 1.tomcat的应用默认放在webapps目录下面,可以将其放在其他目录分区,让tomcat进行管理吗? 答:当然可以.方法:配置虚拟目录 ...

  2. 注册页面的简单搭建(H5)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  3. Javascript中Number()、parseIn()和parseFloat()的区别

    有3个函数可以把非数值转化成数值:Number().parseInt()和parseFloat().第一个函数,即转型函数Number()可以用于任何数据类型,而另两个函数则专门用于把字符串转换成数值 ...

  4. time模块学习

    时间三种形式: 1.timestamp   从1970-1-1 00:00到现在经历的秒数 2.string_time   Sat Mar 28 22:24:24 2009 3.struct_time ...

  5. intellij idea exclude from compile后怎么加回来

    File->Settings-> Build,Execution,Deployment->Compiler-> Execludes

  6. 我写了本破书-swift语言实战晋级

    本书是一本介绍Swift实战的实用图书,旨在帮有一定编程基础的童鞋能够快速上手Swift. 本书的结构是先讲解了Swift语言的精要,没有基础的童鞋可以学习,有基础的童鞋可以当做复习. 接着讲解如何用 ...

  7. PostgreSQL Type的创建与Type在函数中的使用

    postgres=# create type complex as(postgres(# r double precision,postgres(# i double precisionpostgre ...

  8. Java泛型01--任意数组中两元素交换

    package com.zl.generic; /** * 交换“任意”数组 中两个元素 */ public class GenericSwapArray { public static void m ...

  9. css样式重写

    //我们经常想修改插件的某一个或几个样式特性,并保留其它的样式.而不是把某个css全部重写一遍. /*原有样式*/.ninew {padding: 0 10px;width: 600px;height ...

  10. oracle冷备份后恢复

    本地恢复 在运行中输入cmd. 在cmd界面中输入sqlplus/nolog进入sql*plus. 以dba身份连接数据库conn sys/你设定的密码 as sysdba. 输入:shutdown ...