当前位置:网站首页>Bash variable -- user defined variable
Bash variable -- user defined variable
2022-07-22 21:26:00 【Ten at eight】
1、 What is a variable
Variables are units of computer memory , The stored values can be changed . When shell When a script needs to save some information , Such as a file name or a number , Just store it in a variable . Each variable has a name , So it's easy to quote it . Using variables can save useful information , Let the system know the user's relevant settings , Variables can also be used to hold temporary information .
2、 Variable setting rules
Variable names can be alphabetized 、 Numbers and underscores , But it can't start with a number . If the variable name is “2name“ It's wrong .
stay bash in , The default type of variables is string , If you want to do a numerical operation , You must revise the specified variable type to numeric .
Connecting values with equal signs for variables , There can be no spaces on the left and right sides of the equal sign .
Value of variable if there is a space , Single or double quotes are required to include .
In the value of the variable , You can use the escape character .
If you need to increase the value of a variable , Then you can stack the variable values . But variables need to be enclosed in double quotes “$ Variable name “ Or use ${ Variable name } contain .
If the result of the command is given to the variable as the value of the variable , You need to use backquotes or $() Include command .
Environment variable name is recommended to be capitalized , Easy to distinguish .
3、 Variable classification
User defined variables
environment variable : This kind of variable mainly stores the data related to the operating environment of the system . The variable name part is fixed , But users can customize environment variables
Position parameter variable : This variable is mainly used to pass parameters or data to the script , Variable name cannot be customized , Variable action is fixed .
Predefined variables : yes bash Variables already defined in , Variable name cannot be customized , Variable action is also fixed .
4、 The local variable ( User defined variables )
Variable definitions ----- #name="shen chao"
Variable superposition ----- #aa=123;bb=456
#aa="$aa"$bb --------aa After superposition of variable values echo by 123456
Variable call ---- #echo $name
Variable view ---- #set
Variable deletion ---- #unset name
边栏推荐
- Buuctf breakthrough diary 04 -- [strong net cup 2019] casual note 1
- 1. Virtualization and container technology
- On the characteristics of filter pseudo protocol
- 5.网络和安全
- [pytorch deep learning practice] learning notes section 4 back propagation
- Buuctf entry diary -- [nctf2019]fake XML Cookbook
- 浅谈 filter伪协议的特性
- Network Accounting - layered structure, OSI communication process, tcp/ip model and 5-layer reference model
- JUC-7.0-线程协作-CountDownLatch
- [lttng learning journey] - a preliminary study of trace view
猜你喜欢
[GXYCTF2019]BabyUpload1
第二章:minio单机版,使用客户端备份文件
JUC-6.3-并发容器-队列
BUUCTF闯关日记--[NCTF2019]Fake XML cookbook
[pytorch deep learning practice] learning notes section III gradient decline
Buuctf breakthrough diary 04 -- [strong net cup 2019] casual note 1
第四章:minio的presigned URLs上传文件
Pytorch custom data set loading (label in CSV file)
BUUCTF闯关日记--[极客大挑战 2019]HardSQL1
Problems and solutions of using libsvm-3.23 in matlab2017a environment
随机推荐
Set colSpan invalidation for TD of table
[lttng learning journey] - a preliminary study of trace view
Juc-7.2-thread collaboration condition
人类群星网站收集计划--Michael Kerrisk
YOLO9000: Better, Faster, Stronger
Nssctf-01-[swpuctf 2021 freshman competition]gift_ F12
Chapter 8: custom exception return
6. Manage servers and services
Buuctf entry diary -- [suctf 2019]checkin1()
BUUCTF闯关日记--[MRCTF2020]Ez_bypass1
4. Text editor
8. Memory and disk management
Bash变量--用户自定义变量
Bishett route - hyperspectral image classification with deep learning in pytorch environment
Buuctf breakthrough diary 04 -- [strong net cup 2019] casual note 1
Buuctf entry diary -- [nctf2019]fake XML Cookbook
matlab中 FFT 的意义 学习记录
5. Network and security
Software package management RPM package management checksum file extraction
【PyTorch深度学习实践】学习笔记 第三节 梯度下降