当前位置:网站首页>Shell positional parameter variables and predefined variables
Shell positional parameter variables and predefined variables
2022-06-29 23:44:00 【Xiaojing, who likes dumplings】
Position parameter variable
| Position parameter variable | effect |
|---|---|
| $n | n Is the number ,$0 For the order itself ,$1- 9 generation surface The first One individual To The first Nine individual ginseng Count , Ten With On Of ginseng Count Need to be want use Big enclosed Number package contain , Such as 9 Represents the first to ninth parameters , More than ten parameters need to be enclosed in braces , Such as 9 generation surface The first One individual To The first Nine individual ginseng Count , Ten With On Of ginseng Count Need to be want use Big enclosed Number package contain , Such as {10} |
| $* | This variable codes all the arguments in the command line ,$* Treat all parameters as a whole |
| [email protected] | This variable also represents all the parameters on the command line , however [email protected] Treat each parameter differently |
| $# | This variable codes the number of all parameters in the command line |
∗ and * and ∗ and @ The difference between
#$* All parameters in the are considered as a whole , So this for Loop only once
#!/bin/sh
for i in "$*"
do
echo "The parma is : $i"
done
Running results :
The parma is : 1 2 3 4 5 6
#[email protected] Each parameter in is treated as independent , therefore ,[email protected] There are several parameters in , It's going to cycle a couple of times
#!/bin/sh
x=1
for x in "[email protected]"
do
echo "The param $x: is $x"
x=$(($x+1))
done
Running results :
The param 1: is 1
The param 2: is 2
The param 3: is 3
The param 4: is 4
The param 5: is 5
The param 6: is 6
Predefined variables
| Predefined variables | effect |
|---|---|
| $? | Return status of last executed command , If the value of this variable is 0, Prove that the last command was executed correctly , If the value of this variable is not 0, Prove that the last command was not executed correctly |
| $$ | The process number of the current process (PID) |
| $! | The process number of the last process running in the background (PID) |
边栏推荐
- LC:有效的数独 + 旋转图像
- 绿树公司官方网站
- How to solve the problem that the computer time is not automatically updated after proofreading
- 111. simple chat room 14: chat room client
- 搭建企业级NTP时间服务器
- What is online account opening? In addition, is it safe to open a mobile account?
- 6.28日刷题题解
- 这个简单的小功能,半年为我们产研团队省下213个小时
- “微博评论”的高性能高可用计算架构
- Speech signal processing (III): speech signal analysis [continuous "analog signal" -- Sampling, quantization, coding -- > discrete "digital signal"]
猜你喜欢

Speech signal processing (II): phonation physiology, auditory physiology and auditory psychology

High performance and high availability computing architecture of "Weibo comments"

@Scheduled annotation pit, I stepped on it for you
discrete "digital signal"]"/>Speech signal processing (III): speech signal analysis [continuous "analog signal" -- Sampling, quantization, coding -- > discrete "digital signal"]

LC: maximum subarray and

matlab习题 —— 程序控制流程练习

LC:最大子数组和

SQL question brushing 595 Big country

Why is JSX syntax so popular?

High performance and high availability computing architecture of "microblog comments" in microblog system
随机推荐
I hope you have no regrets about the regrettable things in the University
2022 PMP project management examination agile knowledge points (5)
Procurement intelligence is about to break out, and the "3+2" system of Alipay helps enterprises build core competitive advantages
云服务器的安全设置常识
Constexpr function
6.29日刷题题解
剑指 Offer 13. 机器人的运动范围
pytest初始化和清理环境
均值、方差、标准差、协方差的概念及意义
M1笔记本居家办公的痛点及解决方案 | 社区征文
关于二叉树
请指教什么是在线开户?另外,手机开户安全么?
Applet plug-in access, development and precautions
Et la tarte aux framboises 4? Quels sont les jeux possibles?
新钛云服荣膺“2022爱分析 · IT运维厂商全景报告”云管理平台CMP 代表厂商!...
Head on Amway! Good looking and practical motor SolidWorks model material see here
剑指 Offer 14- I. 剪绳子
正则表达式:字符(2)
Golang泛型的巧妙应用,防止变量空指针错误,防止结构体字段空指针错误
xutils3传集合