当前位置:网站首页>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
边栏推荐
猜你喜欢

Li Kou 1358 -- number of substrings containing all three characters (double pointer)

为什么LTD独立站就是Web3.0网站!

明明设计的是高带宽,差点加工成开路?

Properties of 15MnNiNbDR low temperature vessel steel, Wugang 15MnNiDR and 15MnNiNbDR steel plates

Dynamic proxy

动态代理

如何做好固定资产管理?易点易动提供智能化方案

Qt的模型与视图

你了解数据是如何存储的吗?(C整型和浮点型两类)

Principle and application of single chip microcomputer - principle of parallel IO port
随机推荐
Shell脚本-read命令:读取从键盘输入的数据
集团公司固定资产管理的痛点和解决方案
中考体育项目满分标准(深圳、安徽、湖北)
Model and view of QT
电视机尺寸与观看距离
What is the material of 16MnDR, the minimum service temperature of 16MnDR, and the chemical composition of 16MnDR
Shell脚本-while循环详解
日常办公耗材管理解决方案
Matlab tips (16) consistency verification of matrix eigenvector eigenvalue solution -- analytic hierarchy process
Audio audiorecord create (I)
如何一站式高效管理固定资产?
Introduction to R language
win7 pyinstaller打包exe 后报错 DLL load failed while importing _socket:参数错误
Personal decoration notes
毕业季,我想对你说
任务、线程、进程 区别
【MFC开发(17)】高级列表控件List Control
爬虫知识点总结
Advanced API
性能提升2-3倍!百度智能云第二代昆仑芯服务器上线