当前位置:网站首页>Two methods of shell script parameter passing based on arm5718
Two methods of shell script parameter passing based on arm5718
2022-06-28 04:04:00 【Caterpillar's father】
Preface
Usually, many scripts have parameter options , similar :
./test.sh -f config.conf -v --prefix=/home
How to write this script ?
One 、Shell Explanation of special parameters
Let's start with a few special variables :$0, $#, $*, [email protected], $?, $$, $_
Example 1: Create a new one test.sh The file of
#!/bin/bash
echo $0 # File name of the current script ( The indirect runtime also includes absolute paths ).
echo $n # Parameters passed to a script or function .n It's a number , Indicates the number of parameters . for example , The first parameter is $1 .
echo $# # Number of arguments passed to script or function .
echo $* # All parameters passed to a script or function .
echo [email protected] # All parameters passed to a script or function . By double quotes (" ") Inclusion time , And $* Different , I'll talk about .
echo $? # Exit status of last command , Or the return value of the function .
echo $$ # At present Shell process ID. about Shell Script , It's the process of these scripts ID.
echo $_ # The last parameter of the last command
echo $! # Of the last process running in the background ID Number
The results are as follows :
$ ./test.sh test test1 test2 test3 test4
./test.sh # $0
# $n
5 # $#
test test1 test2 test3 test4 # $*
test test1 test2 test3 test4 # [email protected]
0 # $?
12305 # $$
12305 # $_
# $!
$* and [email protected] Represents all parameters passed to a function or script
边栏推荐
- 组件拆分实战
- Analysis of future teacher research ability under steam education framework
- Building log analysis system with elk (III) -- Security Authentication
- Detailed explanation of KVM common commands
- iptables防火墙规则和firewalld防火墙规则详解
- Are the two flame retardant standards of European furniture en 597-1 and en 597-2 the same?
- MSC 307(88) (2010 FTPC Code)第2部分烟气和毒性测试
- 关于 SY8120I 的DC-DC的降压芯片的学习(12V降至3.3V)
- KVM常用命令详解
- 利用ELK 搭建日志分析系统(二)—— 部署安装
猜你喜欢

Are the two flame retardant standards of European furniture en 597-1 and en 597-2 the same?

错排兼排列组合公式

Detailed explanation of iptables firewall rules and firewalld firewall rules

2022年6月对自己近况的一次总结

La norme européenne en 597 - 1 pour les meubles est - elle la même que les deux normes en 597 - 2 pour les ignifuges?

leetcode:494.数组中添加加减运算符得到指定值的所有方法

Detailed explanation of KVM common commands

利用 telegraf influxdb grafana 搭建服务器监控平台

Several important physical concepts

A preliminary study of blackbody radiation
随机推荐
Building a server monitoring platform with telegraf influxdb grafana
MSc 307 (88) (2010 FTPC code) Part 9 bedding test
第一章 Bash 入门
加法器—笔记
Does the applet input box flash?
Building log analysis system with elk (III) -- Security Authentication
Arrangement of basic electrical knowledge (I)
05 MongoDB对列的各种操作总结
利用ELK 搭建日志分析系统(一)—— 组件介绍
Several ways of sharing printers in LAN
MSC 307(88) (2010 FTPC Code)第2部分烟气和毒性测试
谈云原生,不得不谈的容器
A preliminary study of blackbody radiation
English grammar_ Adjective / adverb Level 3 - Comparative_ Useful Expressions
欧洲家具EN 597-1 跟EN 597-2两个阻燃标准一样吗?
Door level modeling - learning notes
以自动化赋能转型,飞鹤乳业加速迈向数字化!
软件测试报告怎么编写?第三方性能报告范文模板来了
小程序输入框闪动?
Open the field of maker education and creation