当前位置:网站首页>Basic series of SHEL script (I) variables
Basic series of SHEL script (I) variables
2022-07-05 07:19:00 【jiankang66】
One 、 background
Although I am a java The programmer , Do the back end , But recently, I often need to read scripts written by others to run projects , So as a back-end programmer , We also need to know shell grammar , Can read some basic shell Script .
Two 、 Variable correlation
1、 Variable assignment
(1) Assignment of common variables
a="hello world"(2) Assign values to variables through commands , Two ways .
a=$(pwd)
b=`uname`2、 Cancel variables
unset A3、 Get the length of the variable
${#b}4、 Deletion of variable content
(1) Delete Syntax
% | Means to remove the first matching from right to left |
%% | Remove all matching from right to left |
# | Means to remove the first matching from left to right |
## | Means to remove all matching from left to right |
eg:
# return text
a=a.txt
echo ${a##*.}4、 Replacement of variable contents
(2) Substitution grammar
${ Variable name / The old value / The new value }
eg:
# return b.txt
a=a.txt
echo ${a/a/b}5、 Print variables
(1) Mode one
echo $a(2) Mode two
echo ${a}6、 Query environment variables
(1) View the current environment variables
env(2) Filter environment variables
env | grep Name(3) Support filtering common variables or environment variables
set | grep Name7、 Define an environment variable
(1) Mode one
declare -x BBB=jiankang(2) Mode two
export DDD=jiankang8、 Global variable profile
(1) Required after change source Let it take effect
Configure environment variables globally | /etc/profile |
| Current user's environment variables | home/.bash_profile |
| Current user's bash Information | /home/.bashrc |
| Global effective for all users bash Information | /etc/bashrc |
9、 System variables
| $? | Whether the last command is executed normally 0 Is normal ( really ) Not 0 Indicates an execution exception |
| $0 | Name of the currently executing program or script |
| $# | The number of parameters passed after the script |
| $* | All the parameters behind the script , Comma separated |
| [email protected] | All the parameters behind the script |
| $1 | The first parameter following the script |
| $9 | The ninth parameter following the script |
| ${10} | The tenth parameter following the script |
| $$ | The process number of the current process |
$! | The last process number running in the background ( Current terminal ) |
| !$ | Call the parameters in the last command history |
3、 ... and 、 summary
The above is about shell Everything about syntax variables , Hopefully that helped , You can refer to it , If you think it's good , Welcome to wechat search java Basic notes , Relevant knowledge will be continuously updated later , Make progress together .
边栏推荐
- 【软件测试】02 -- 软件缺陷管理
- 剑指 Offer 56 数组中数字出现的次数(异或)
- Matrix and TMB package version issues in R
- Ethtool principle introduction and troubleshooting ideas for network card packet loss (with ethtool source code download)
- 并查集理论讲解和代码实现
- [node] NVM version management tool
- Course learning accumulation ppt
- npm install -g/--save/--save-dev的区别
- How can Oracle SQL statements modify fields that are not allowed to be null to allow nulls?
- 氫氧化鈉是什麼?
猜你喜欢

Powermanagerservice (I) - initialization
![[software testing] 02 -- software defect management](/img/2f/9987e10e9d4ec7509fa6d4ba14e84c.jpg)
[software testing] 02 -- software defect management

docker安装mysql并使用navicat连接

Do you choose pandas or SQL for the top 1 of data analysis in your mind?

Solve tensorfow GPU modulenotfounderror: no module named 'tensorflow_ core. estimator‘
![[untitled]](/img/d5/2ac2b15818cf66c241e307c6723d50.jpg)
[untitled]

并查集理论讲解和代码实现

PHY drive commissioning --- mdio/mdc interface Clause 22 and 45 (I)
![[software testing] 03 -- overview of software testing](/img/1e/0b6458160e34e43f021ea4797de70a.jpg)
[software testing] 03 -- overview of software testing

611. 有效三角形的个数
随机推荐
DataGrid offline installation of database driver
Simple operation with independent keys (hey, a little fancy) (keil5)
Ros2 topic (VIII)
The difference between new and malloc
How can Oracle SQL statements modify fields that are not allowed to be null to allow nulls?
SD_ CMD_ RECEIVE_ SHIFT_ REGISTER
PHY drive commissioning --- mdio/mdc interface Clause 22 and 45 (I)
氢氧化钠是什么?
Simple operation of nixie tube (keil5)
npm install -g/--save/--save-dev的区别
The problem of configuring opencv in qt5.13.2 is solved in detail
The golang timer uses the stepped pit: the timer is executed once a day
Reading literature sorting 20220104
并查集理论讲解和代码实现
Simple operation of running water lamp (keil5)
SOC_SD_CMD_FSM
ORACLE CREATE SEQUENCE,ALTER SEQUENCE,DROP SEQUENCE
[tf1] save and load parameters
[untitled]
Database SQL practice 4. Find the last of employees in all assigned departments_ Name and first_ name