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

实例:

$ vim dollar.sh

#!/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"
printf "The complete list is %s\n" "$3"

结果展示:

[sunny@xxxx ]$ sh dollar.sh   qq ww
The complete list is
The complete list is
The complete list is
The complete list is qq ww
The complete list is
The complete list is
The complete list is qq
The complete list is ww
The complete list is
The complete list is dollar.sh
The complete list is
The complete list is
The complete list is qq

Linux中shell变量$0,$?等含义的更多相关文章

  1. linux中shell变量$#,$@,$0,$1,$2

    linux中shell变量$#,$@,$0,$1,$2的含义解释: 变量说明: $$ Shell本身的PID(ProcessID) $! Shell最后运行的后台Process的PID $? 最后运行 ...

  2. (转载)linux中shell变量

    (转载)http://blog.csdn.net/zahuopuboss/article/details/8633891 为使shell编程更有效,系统提供了一些shell变量.shell变量可以保存 ...

  3. linux中shell变量$#,$@,$0,$1,$2的含义解释<转>

    linux中shell变量$#,$@,$,$,$2的含义解释: 变量说明: $$ Shell本身的PID(ProcessID) $! Shell最后运行的后台Process的PID $? 最后运行的命 ...

  4. linux中shell变量$#,$@,$0,$1,$2的含义解释

    linux中shell变量$#,$@,$0,$1,$2的含义解释: 变量说明: $$ Shell本身的PID(ProcessID) $! Shell最后运行的后台Process的PID $? 最后运行 ...

  5. linux中shell变量$#,$@,$0,$1,$2的含义解释

    linux中shell变量$#,$@,$0,$1,$2的含义解释 linux中shell变量$#,$@,$0,$1,$2的含义解释:  变量说明:  $$  Shell本身的PID(ProcessID ...

  6. 【转】linux中shell变量$#,$@,$0,$1,$2的含义解释

    原文网址:http://www.cnblogs.com/fhefh/archive/2011/04/15/2017613.html linux中shell变量$#,$@,$0,$1,$2的含义解释: ...

  7. 【Shell】linux中shell变量$#,$@,$0,$1,$2的含义解释 && set 关键字使用

    linux中shell变量$#,$@,$0,$1,$2的含义解释   摘抄自:ABS_GUIDE 下载地址:http://www.tldp.org/LDP/abs/abs-guide.pdf linu ...

  8. linux中shell变量$#,$@,$0,$1,$2的含义

    linux中shell变量$#,$@,$0,$1,$2的含义解释: 变量说明: $$ Shell本身的PID(ProcessID) $! Shell最后运行的后台Process的PID $? 最后运行 ...

  9. 浅谈linux中shell变量$#,$@,$0,$1,$2,$?的含义解释

    浅谈linux中shell变量$#,$@,$0,$1,$2,$?的含义解释 下面小编就为大家带来一篇浅谈linux中shell变量$#,$@,$0,$1,$2的含义解释.小编觉得挺不错的,现在就分享给 ...

随机推荐

  1. Cortex_M3——存储器系统学习笔记

    看完一个章节完全不做学习笔记总结并进行知识转换,看了就会忘记啊~无奈脸. 一.CORTEX_M3总线一览 二.异常 编号为1-15的对应系统异常,大于等于16的则全是外部中断. 系统异常清单如下所示: ...

  2. [转载]ORACLE EXP/IMP

    转载自:https://www.cnblogs.com/mengfanrong/p/3792955.html 本文对Oracle数据的导入导出 imp ,exp 两个命令进行了介绍, 并对其对应的參数 ...

  3. java 注解总结

    @Controller用于标注控制层组件 @Controller 用于标记在一个类上,使用它标记的类就是一个SpringMVC Controller 对象.分发处理器将会扫描使用了该注解的类的方法.通 ...

  4. Hadoop/Spark入门学习笔记(完结)

    Hadoop基础及演练 ---第1章 初识大数据 大数据是一个概念也是一门技术,是在以Hadoop为代表的大数据平台框架上进行各种数据分析的技术. ---第2章 Hadoop核心HDFS Hadoop ...

  5. AS中几个较好的插件

    Android ButterKnife Zelezny   自动生成依赖注入代码 Android Parcelable code generator  自动生成Parcelable代码 Selecto ...

  6. 片段的findFragmentById

    class类名 名字 = calss类名 getFragmentManager().findFragmentById(R.id.布局id) 因为需要获取到片段的管理者,才可以去寻找到相应的布局.

  7. Windows10解决无法访问其他机器共享的问题

    你不能访问此共享文件夹,因为你组织的安全策略阻止未经身份验证的来宾访问.这些策略可帮助保护你的电脑免受网络上不安全设备或恶意设备的威胁. 管理员身份执行sc.exe config lanmanwork ...

  8. oracle之 RAC 11G ASM下控制文件多路复用

    如果数据库仅有一组control file文件,需要添加一组或者多组,保证一组文件损坏或者丢失导致数据库宕机. -- 环境说明SQL> select * from v$version;BANNE ...

  9. Mysql的“Table 'mysql.servers' doesn't exist”的解决方法

    安装MYSQL后,又一次系统出现问题了,于是我查看mysql的错误日志,竟发现Table 'mysql.servers' doesn't exist问题的错误, 虽然与我的问题无关,但这个问题还是引起 ...

  10. Data_Structure03-栈和队列

    一.学习总结 1.写出你认为本周学习中比较重要的知识点关键词 ·抽象数据类型 ·栈和队列 2.思维导图 二.PTA实验作业 选题: 1.7-1 jmu-字符串是否对称(20 分) 2.7-4(选做) ...