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. 数据库链接池 durid 的配置参数详解

    这里我主要介绍druid 比较重要的参数解释,不做druid的使用介绍,druid虽然功能强大,但是如果对配置参数理解不到位,性能非但不能达到很优,而且会出现很多异常,所以使用druid之前一定要清楚 ...

  2. Python3 元组Tuple(十二)

    元组:tuple.tuple和list非常类似,但是tuple一旦初始化就不能修改 元组使用小括号,列表使用方括号. 元组创建很简单,只需要在括号中添加元素,并使用逗号隔开即可. 如下实例: tup1 ...

  3. JSP session过期时间(小记)

    以下情况,Session结束生命周期,Servlet容器将Session所占资源释放:1.客户端关闭浏览器2.Session过期3.服务器端调用了HttpSession的invalidate()方法. ...

  4. jsp如何判断mysql数据库中是否已经存在添加的某条记录的方法

    String query="select * from hdxcy_info where XcyName='"+XcyName+"'"; String sqlS ...

  5. 严重: Dispatcher initialization failed java.lang.RuntimeException: java.lang.reflect.InvocationT

    严重: Dispatcher initialization failed java.lang.RuntimeException: java.lang.reflect.InvocationT (2012 ...

  6. java并发编程之二--CountDownLatch的使用

    CountDownLatch类 允许一个或多个线程等待直到在其他线程中执行的一组操作完成的同步辅助. CountDownLatch能够使一个线程在等待另外一些线程完成各自工作之后,再继续执行.使用一个 ...

  7. zabbix利用python脚本发送钉钉报警

    #!/usr/bin/python # -*- coding: utf-8 -*- import requests import json import sys import os headers = ...

  8. ZetCode PyQt4 tutorial layout management

    !/usr/bin/python -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial This example shows ...

  9. .NET IL指令速查表

    名称 说明 Add 将两个值相加并将结果推送到计算堆栈上. Add.Ovf 将两个整数相加,执行溢出检查,并且将结果推送到计算堆栈上. Add.Ovf.Un 将两个无符号整数值相加,执行溢出检查,并且 ...

  10. 使用TortoiseGit+码云管理项目代码

    1.下载安装msysgit. 2.下载安装tortoisegit. 3.创建ssh密钥. 开始–所有程序–TortoiseGit–PuTTYgen 生成方法:点击“Generate”后,鼠标在key下 ...