当前位置:网站首页>List of shell script special variables
List of shell script special variables
2022-07-21 17:09:00 【Cloud computing security】
Author:rab
A thousand times , You can have a look at what you haven't remembered yet , Passers by can also take a glance , These are a few shell Can you distinguish the special variables of the script ?
Variable | paraphrase |
---|---|
$0 | Get the name of the currently executed script . Such as :sh ./hello.sh Then the value of this variable is ./hello.sh |
$# | Get the number of parameters passed to the script or function ( Count ) |
$* | Get all the parameters passed to the script or function ( value )-- Space off |
[email protected] | Get all the parameters passed to the script or function ( value )-- Space off |
$n | Get the parameters passed to the script or function ( value ). Such as :sh hello.sh aa bb that $1 The variable value is aa ,$2 The variable value is bb |
#? | Get the exit status of the last command or function . success :0 Failure : Not 0 |
$$ | Get the process that currently executes the script PID |
Be careful ️️️
Notice here $* and [email protected] The difference between
, Without double quotation marks (" ") Under the circumstances , The two values are exactly the same , But with double quotation marks , We need to pay attention to :
No double quotes : There's no difference between the two , It's all about
"$1" "$2" ... "$n"
Format output .# for example sh hello.sh aa bb cc # $* and [email protected] Output $*:aa bb cc [email protected]:aa bb cc
There are double quotation marks : There is a difference between the two ,
"$*"
The output format is"$1 $2 ... $n"
, That is, an overall output ."[email protected]"
The output format remains the same as when there are no double quotes .# for example sh hello.sh aa bb cc # $* and [email protected] Output ( It looks the same , however "$*" The value of is a whole , That is to say aa bb cc Is a value with spaces , and "[email protected]" Are three independent values separated by spaces ) "$*":aa bb cc "[email protected]":aa bb cc ================================ # If you use one for Loop to get the value for i in "$*" do echo $i done for i in "[email protected]" do echo $i done # $* and [email protected] Output ("$*" Only one cycle , Because it has only one value , and "[email protected]" But it has been cycled three times , Because it has three values ) "$*":aa bb cc "[email protected]": aa bb cc
complete !
边栏推荐
- 4.76 million. Targeted procurement of Bank of Hebei: F5 load balancing (10 sets)
- 第03篇:SQL语法树解析
- 如何从零开始学习自动化测试?
- 1486. 数组异或操作
- Scala exercises student scores case
- Monitor Deep Learning Training Progress
- K8s drainage error summary (ignoring daemonset management pod, MySQL Cluster drainage error, Mongo cluster drainage error)
- 477. 汉明距离总和
- 第06篇:池化技术
- The top three suddenly changed, revealing the latest ranking of programming languages in July
猜你喜欢
[Baoyan] - oral English skills in Baoyan summer camp
acme自动化---免费SSL证书申请并自动续期
1723. 完成所有工作的最短时间
Monitor Deep Learning Training Progress
[Baoyan] - answer to open questions in Baoyan summer camp
LeetCode 1260 二维网格迁移[数组] HERODING的LeetCode之路
Use of oil monkey plug-in
如何做好测试管理?
主成分分析及SPSS的使用------笔记
938. Range and of binary search tree
随机推荐
Let me tell you how a grass-roots programmer can counter attack and successfully enter bat!
Typescript函数扩展使用
Games101 graphics P10 notes (geometry1)
這份 pip 使用小抄,要有全有多全!
BCG attribute list
Beisen prospectus: the advantages of the track are prominent, and integration + medium and large customers are plus points
[Interview: concurrence19: Multithreading: Park & unpark]
740. 删除并获得点数
【MySQL】在CentOS 7 简单安装
Scala学习第一天(Hello world)
【面试:并发篇19:多线程:Park&Unpark】
How project managers do a good job in "boss" projects
相关性分析及SPSS软件操作
Use of oil monkey plug-in
477. Sum of Hamming distance
第03篇:SQL语法树解析
1720. Array after XOR decoding
入门软件测试小知识点
Summary of APP page seconds open optimization~
百度工程师眼中的云原生可观测性追踪技术