当前位置:网站首页>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
边栏推荐
- Mobile finance (for personal use)
- Spark 算子之coalesce与repartition
- 导入地址表分析(根据库文件名求出:导入函数数量、函数序号、函数名称)
- 单体架构系统重新架构
- 【AI周报】英伟达用AI设计芯片;不完美的Transformer要克服自注意力的理论缺陷
- Upgrade MySQL 5.1 to 5.68
- Calculate the number of occurrences of a character
- 网站压测工具Apache-ab,webbench,Apache-Jemeter
- The El tree implementation only displays a certain level of check boxes and selects radio
- c语言---指针进阶
猜你喜欢
The principle and common methods of multithreading and the difference between thread and runnable
JVM-第2章-类加载子系统(Class Loader Subsystem)
One brush 314 sword finger offer 09 Implement queue (E) with two stacks
王启亨谈Web3.0与价值互联网“通证交换”
大型互联网为什么禁止ip直连
For examination
Today's sleep quality record 76 points
Codejock Suite Pro v20.3.0
Spark 算子之交集、并集、差集
多级缓存使用
随机推荐
shell_2
Multitimer V2 reconstruction version | an infinitely scalable software timer
时序模型:长短期记忆网络(LSTM)
Upgrade MySQL 5.1 to 5.68
API IX JWT auth plug-in has an error. Risk announcement of information disclosure in response (cve-2022-29266)
大厂技术实现 | 行业解决方案系列教程
The length of the last word of the string
现在做自媒体能赚钱吗?看完这篇文章你就明白了
Modèle de Cluster MySQL et scénario d'application
怎么看基金是不是reits,通过银行购买基金安全吗
Large factory technology implementation | industry solution series tutorials
Go语言条件,循环,函数
【AI周报】英伟达用AI设计芯片;不完美的Transformer要克服自注意力的理论缺陷
IronPDF for . NET 2022.4.5455
Fastjon2 here he is, the performance is significantly improved, and he can fight for another ten years
Mumu, go all the way
Upgrade MySQL 5.1 to 5.67
导入地址表分析(根据库文件名求出:导入函数数量、函数序号、函数名称)
Timing model: gated cyclic unit network (Gru)
For examination