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参数…。
示例:
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 ~]$ bashparams.sh 123456 QQ
The complete listis24249
The complete listis
The complete listis0
The complete listis123456 QQ
The complete listis123456
The complete listisQQ
The complete listis2
The complete listisparams.sh
The complete listis123456
The complete listisQQ
Have a nice day!!!
随机推荐
- SharePoint 2010 隐藏快速启动栏之使用内容编辑器webpart
SharePoint 2010 自带的webpart里有一个叫内容编辑,在媒体和内容分类里面: 将其添加到页面后效果: 点击用于添加新内容,此时注意Ribbon菜单中的变化: 这里可以看到,你可以插入 ...
- Python yield 使用浅析(转)
Python yield 使用浅析 初学 Python 的开发者经常会发现很多 Python 函数中用到了 yield 关键字,然而,带有 yield 的函数执行流程却和普通函数不一样,yield 到 ...
- liunx下安装MYSQL时需要安装的相关软件的作用
2013年11月16日 14:18:39 This installs the package for MySQL server (mysql-community-server) and also pa ...
- 使用eclipse开发Java web应用
前面说了手动配置一个应用,手动配置可以更深入的理解web应用的分布,但是一般的编辑器没有语法错误提示,所以开发起来对于错误的寻找不太容易,效率相对较低,所以在理解清楚web项目的结构之后,我们使用ec ...
- Java for LeetCode 152 Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest ...
- MVC @helper (转载)
转载地址:http://gaoling386.blog.163.com/blog/static/5404602420130595842894/ ASP.NET MVC 3支持一项名为“Razor”的新 ...
- poj 3264 RMQ 水题
题意:找到一段数字里最大值和最小值的差 水题 #include<cstdio> #include<iostream> #include<algorithm> #in ...
- java线程安全总结
转自:http://blog.csdn.net/haolongabc/article/details/7249098 最近想将java基础的一些东西都整理整理,写下来,这是对知识的总结,也是一种乐趣. ...
- Android虚拟机中的sqlite数据库文件
Android虚拟机中的sqlite数据库文件 ①
- P and V
上次,我们已经说过死锁的形成原因以及防止方法了,都知道,之所以会发生死锁现象,原因之一是进程执行所申请的资源得不到满足,而陷入无限期的循环等待现象,而在这里我们说的进程其实是并发进程,也就是一组,至少 ...