当前位置:网站首页>Bash变量--位置参数变量
Bash变量--位置参数变量
2022-07-22 10:51:00 【八点十面】
1、位置参数变量
位置参数变量 | 作用 |
$n | n为数字,$n代表命令本身。$1-$9代表第一到第九个参数,十个以上的参数需要用大括号包含,如${10} |
$* | 这个变量代表命令行中所有的参数,$*把所有的参数看成一个整体 |
这个变量也代表命令行中所有的参数,不过[email protected]把每个参数区分对待 | |
$# | 这个变量代表命令行中所有参数的个数 |
$n --------参看~/sh/canshu1.sh ~/sh/canshu2.sh
另三个参看~/sh/canshu3.sh
Bash变量—预定义变量
1、预定义变量
预定义变量 | 作用 |
$? | 最后一次执行的命令的返回状态。如果这个变量的值为0,证明上一个命令正确执行;如果这个变量的值为非0,则证明上一个命令执行不正确。 |
$$ | 当前进程的进程号(PID) |
$! | 后台运行的最后一个进程的进程号(PID) |
参见~/sh/canshu4.sh
2、接收键盘输入
#read [选项] [变量名]
-p"提示信息“ : 在等待read输入时,输出提示信息
-t秒数 : read命令会一直等待用户输入,使用此选项可以指定等待命令
-n字符数: read命令只接受指定的字符数,就会执行。
-s : 隐藏输入的数据,适用于机密信息的输入。
参见~/sh/canshu5.sh
边栏推荐
- Servlet
- Redis 系列12--Redis 主从
- Django中使用Mysql数据库
- Parasitic sensing common centroid binary weighted capacitor layout generation integrates layout, wiring, and cell capacitor size
- Redis series 14 -- redis cluster
- Using various weighting methods to place binary weighted capacitor array in SAR ADC
- 有源和无源设备的共质心布局:回顾和未来之路
- 项目中手机、姓名、身份证信息等在日志和响应数据中脱敏操作
- Eight sorts (direct insertion sort)
- A new checkerboard placement and sizing method for capacitors in charge scaling DAC based on nonlinear worst-case analysis
猜你喜欢
多线程04--线程的原子性、CAS
Leetcode high frequency question: what is the difference between the combat effectiveness of the two soldiers with the closest combat effectiveness of N soldiers in the challenge arena
具有任意电容比的共质心电容阵列的自动生成
postman接口测试
Django中使用Mysql数据库
Multithread 07 -- ThreadLocal
微信小程序入门教程学习笔记——UI篇之操作反馈
模拟电路中晶体管阵列的性能感知公共质心布局和布线 ALIGN
Redis series 12 -- redis master-slave
C language (Itoa function)
随机推荐
Tree structure
ETL过程
Install pycharm
Simulated student information input interface
postman接口测试
Pytest testing framework built quickly
Matching of MOS transistors with different layout styles
Automatic current mirror layout (acml) tool
Redis series 13 -- redis Sentinel
MATLAB2017a环境下使用libsvm-3.23出现的问题与解决方案
jvm原理与性能调优
Monkey 介绍及使用
Redis 系列13--Redis 哨兵
Data transfer from one Mysql to another MySQL
【FPGA】:ip核-DDS
Thread pool 02 -- source code
【FPGA】:aurora核的使用
Airtest 进行WebUI自动化测试(selenium)
电荷分级DAC中二元加权电容器的寄生感知大小和详细路由
ThreadLocal遇到线程池出现数据问题和解决方案