当前位置:网站首页>shell_ two
shell_ two
2022-04-23 15:46:00 【Mo Chi_】
grammar
1. Judge
# [ ] Leave a space on the left and right of the variable in the middle
if [ -d $0 ]; then
echo "this is dir"
elif [ -f $0 ]; then
echo "this is file"
else
echo "Nothing"
fi
2. loop
# seq : sequence: shell Sequence , Fully closed interval
for i in `seq 1 10`
do
echo "current num is $i"
done
Equate to :
for ((i=1; i<11; i++)); do echo "current num is $i"; done
3. function
foo() {
echo "Hello Shell"
for f in `ls ../`
do
echo $f
done
}
# Calling a function does not require ()
foo
Be careful :
When defining a function , Variable name preceded by function and No addition function All right
4. case: Execute the corresponding action statement when there are conditions that match , Otherwise, quit
cat << EOF
Please enter the operation number to be performed :【1-4】
==========================
【1】 The system update
【2】 Install the software
【3】 install Redis
【4】 install Nginx
=========================
EOF
# Get the operation number to be performed
if [[ -n $1 ]]; then
input=$1
echo " Perform the operation : $1"
else
read -p " Please select : " input
fi
case $input in
1) system_update;;
2) install_software;;
3) install_redis;;
4) install_nginx;;
*) exit;;
esac
版权声明
本文为[Mo Chi_]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231543352873.html
边栏推荐
- 基础贪心总结
- s16. One click installation of containerd script based on image warehouse
- Node. JS ODBC connection PostgreSQL
- Spark 算子之groupBy使用
- fatal error: torch/extension. h: No such file or directory
- What is CNAs certification? What are the software evaluation centers recognized by CNAs?
- PHP function
- Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
- Mobile finance (for personal use)
- APISIX jwt-auth 插件存在错误响应中泄露信息的风险公告(CVE-2022-29266)
猜你喜欢
Cap theorem
cadence SPB17.4 - Active Class and Subclass
多级缓存使用
Recommended search common evaluation indicators
MySQL Cluster Mode and application scenario
大型互联网为什么禁止ip直连
Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
C language --- string + memory function
多生成树MSTP的配置
Spark 算子之distinct使用
随机推荐
Cookie&Session
One brush 314 sword finger offer 09 Implement queue (E) with two stacks
JVM - Chapter 2 - class loader subsystem
Upgrade MySQL 5.1 to 5.67
pgpool-II 4.3 中文手册 - 入门教程
怎么看基金是不是reits,通过银行购买基金安全吗
Basic greedy summary
字符串排序
Interview questions of a blue team of Beijing Information Protection Network
KNN, kmeans and GMM
Config learning notes component
王启亨谈Web3.0与价值互联网“通证交换”
携号转网最大赢家是中国电信,为何人们嫌弃中国移动和中国联通?
贫困的无网地区怎么有钱建设网络?
多线程原理和常用方法以及Thread和Runnable的区别
How did the computer reinstall the system? The display has no signal
Go并发和通道
为啥禁用外键约束
北京某信护网蓝队面试题目
Spark 算子之distinct使用