当前位置:网站首页>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
边栏推荐
- Meichuang data security management platform has obtained the evaluation certificate of "data security product capability verification plan" of the Institute
- Pycharm setting pseudo sublime color scheme
- 一文告诉你什么是 Kubernetes
- 开关电源—Buck电路原理及其仿真
- 《性能之巅第2版》阅读笔记(二)--CPU监测
- 几个重要的物理概念
- 如何修改SE38编辑器主题
- 多项目开发入门,基础设计 类库项目使用
- 解析STEAM教育框架下未来教师研究能力
- Learning notes of digital circuit (II)
猜你喜欢

Introduction notes to machine learning

Talking about cloud primitiveness, we have to talk about containers

工业物联网将取代人工发展吗?

Staggered and permutation combination formula

错排兼排列组合公式

ambari SSLError: Failed to connect. Please check openssl library versions.

django. core. exceptions. ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 0.9.3

开关电源—Buck电路原理及其仿真

A Preliminary Study of Blackbody radiation

Pycharm不同项目之间共用第三方模块
随机推荐
leetcode:494. All methods of adding and subtracting operators to the array to get the specified value
Meichuang data security management platform has obtained the evaluation certificate of "data security product capability verification plan" of the Institute
电学基础知识整理(一)
使用tensorboard进行loss可视化
利用ELK 搭建日志分析系统(一)—— 组件介绍
Elk builds log analysis system + Zipkin service link tracking integration
English notes - cause and effect
03 MongoDB文档的各种增加、更新、删除操作总结
【毕业季】研究生の毕业总结
音频 scipy 中 spectrogram 的运作机制
Zipkin 服务链路追踪
vscode中出现无法在只读编辑器中编辑
关于 SY8120I 的DC-DC的降压芯片的学习(12V降至3.3V)
How to apply for ASTM E108 flame retardant test for photovoltaic panels?
歐洲家具EN 597-1 跟EN 597-2兩個阻燃標准一樣嗎?
门级建模—学习笔记
Adder - Notes
Pycharm setting pseudo sublime color scheme
多线程与高并发六:线程池源码解析
A Preliminary Study of Blackbody radiation