当前位置:网站首页>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
边栏推荐
- 避免按钮重复点击的小工具bimianchongfu.queren()
- The era of low threshold programmers is gone forever behind the sharp increase in the number of school recruitment for Internet companies
- 【面试必刷101】链表
- Audio-AudioRecord create(一)
- 毕业季,我想对你说
- Shell脚本-for循环和for int循环
- Yolov3, 4, 5 and 6 Summary of target detection
- Shell脚本-特殊变量:Shell $#、$*、[email protected]、$?、$$
- ARM v7的体系结构A、R、M区别,分别应用在什么领域?
- Full mark standard for sports items in the high school entrance examination (Shenzhen, Anhui and Hubei)
猜你喜欢
随机推荐
任务、线程、进程 区别
电脑小技巧
Memory size end
TV size and viewing distance
What is the material of 16MnDR, the minimum service temperature of 16MnDR, and the chemical composition of 16MnDR
串口转WIFI模块通信
Only in China! Alicloud container service enters the Forrester leader quadrant
Software Engineer Interview Question brushing website and experience method
ARM v7的体系结构A、R、M区别,分别应用在什么领域?
明明设计的是高带宽,差点加工成开路?
Advanced C language pointer (Part 2)
Shell脚本-for循环和for int循环
C语言学生信息管理系统
如何解决固定资产管理和盘点的难题?
《微机原理》-绪论
毕业季,我想对你说
Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched
C语言指针的进阶(上篇)
如何高效拉齐团队认知
19Mn6 German standard pressure vessel steel plate 19Mn6 Wugang fixed binding 19Mn6 chemical composition