当前位置:网站首页>Shell script - special variables: shell $, $*, [email protected], $$$
Shell script - special variables: shell $, $*, [email protected], $$$
2022-07-01 08:47:00 【Little snail's way】
Variable | meaning |
---|---|
$0 | File name of the current script . |
$n(n≥1) | Parameters passed to a script or function .n It's a number , Indicates the number of parameters . for example , The first parameter is $1, The second parameter is $2. |
$# | Number of arguments passed to script or function . |
$* | All parameters passed to a script or function . |
[email protected] | All parameters passed to a script or function . When double quotes " " Inclusion time ,[email protected] And $* not quite the same |
$? | Exit status of last command , Or the return value of the function |
$$ | At present Shell process ID. about Shell Script , It's the process of these scripts ID. |
$* And [email protected] Difference : When wrapped in double quotation marks ,[email protected] There is no change when it is not wrapped in double quotation marks ,[email protected] It's still an array , Each parameter is still separate ; But when $* When wrapped in double quotation marks ,SHELL All parameters will be integrated into one string .
Pass parameters to the script file
The script is as follows :
#!/bin/bash
echo "Process ID: $$"
echo "File Name: $0"
echo "First Parameter : $1"
echo "Second Parameter : $2"
echo "All parameters 1: [email protected]"
echo "All parameters 2: $*"
echo "Total: $#"
Output :
Process ID: 5943
File Name: bash
First Parameter : Shell
Second Parameter : Linux
All parameters 1: Shell Linux
All parameters 2: Shell Linux
Total: 2
边栏推荐
- C language student information management system
- TypeError: __ init__ () got an unexpected keyword argument ‘autocompletion‘
- Audio-AudioRecord create(一)
- [untitled]
- It technology ebook collection
- 电脑小技巧
- 5mo3 UHI HII HII 17mn4 19Mn6 executive standard
- Matlab tips (23) matrix analysis -- simulated annealing
- 易点易动助力企业设备高效管理,提升设备利用率
- 目标检测的yolov3、4、5、6总结
猜你喜欢
Principle and application of single chip microcomputer - principle of parallel IO port
Nacos - 配置管理
[untitled]
TypeError: __init__() got an unexpected keyword argument ‘autocompletion‘
What is the material of 16mo3 steel plate? What is the difference between 16mo3 and Q345R?
TypeError: __ init__ () got an unexpected keyword argument ‘autocompletion‘
Nacos - 服务发现
【C】 Summary of wrong questions in winter vacation
截图小妙招
Foundation: 2 The essence of image
随机推荐
[MFC development (16)] tree control
Full mark standard for sports items in the high school entrance examination (Shenzhen, Anhui and Hubei)
Shell脚本-if else语句
我想知道手机注册股票开户的流程?另外,手机开户安全么?
IT 技术电子书 收藏
Shell脚本-特殊变量:Shell $#、$*、[email protected]、$?、$$
Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched
Shell脚本-for循环和for int循环
MD文档中插入数学公式,Typora中插入数学公式
C语言指针的进阶(上篇)
Insert mathematical formula in MD document and mathematical formula in typora
How can enterprises and developers take the lead in the outbreak of cloud native landing?
Interrupt sharing variables with other functions and protection of critical resources
SPL Introduction (I)
Nacos - Configuration Management
JCL 和 SLF4J
Properties of 15MnNiNbDR low temperature vessel steel, Wugang 15MnNiDR and 15MnNiNbDR steel plates
【MFC开发(16)】树形控件Tree Control
TV size and viewing distance
Embedded Engineer Interview Question 3 Hardware