当前位置:网站首页>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
边栏推荐
- Recommended search common evaluation indicators
- 一刷313-剑指 Offer 06. 从尾到头打印链表(e)
- 网站压测工具Apache-ab,webbench,Apache-Jemeter
- How to test mobile app?
- 多生成树MSTP的配置
- MySQL optimistic lock to solve concurrency conflict
- Spark 算子之distinct使用
- Special analysis of China's digital technology in 2022
- Spark 算子之groupBy使用
- Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
猜你喜欢
Codejock Suite Pro v20.3.0
Special analysis of China's digital technology in 2022
Cookie&Session
Single architecture system re architecture
多级缓存使用
考试考试自用
WPS brand was upgraded to focus on China. The other two domestic software were banned from going abroad with a low profile
Multitimer V2 reconstruction version | an infinitely scalable software timer
【开源工具分享】单片机调试助手(示波/改值/日志) - LinkScope
大型互联网为什么禁止ip直连
随机推荐
考试考试自用
Mobile finance (for personal use)
山寨版归并【上】
移动金融(自用)
Accumulation of applet knowledge points
API IX JWT auth plug-in has an error. Risk announcement of information disclosure in response (cve-2022-29266)
Upgrade MySQL 5.1 to 5.69
Spark 算子之sortBy使用
字符串最后一个单词的长度
控制结构(一)
ICE -- 源码分析
Upgrade MySQL 5.1 to 5.68
为啥禁用外键约束
Config组件学习笔记
pywintypes. com_ Error: (- 2147221020, 'invalid syntax', none, none)
C language --- advanced pointer
Spark 算子之filter使用
网站压测工具Apache-ab,webbench,Apache-Jemeter
Basic concepts of website construction and management
Treatment of idempotency