当前位置:网站首页>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
边栏推荐
- Go language slice, range, set
- Redis主从复制过程
- [leetcode daily question] install fence
- What are the mobile app software testing tools? Sharing of third-party software evaluation
- How to test mobile app?
- What is CNAs certification? What are the software evaluation centers recognized by CNAs?
- fatal error: torch/extension. h: No such file or directory
- IronPDF for .NET 2022.4.5455
- php类与对象
- Extract non duplicate integers
猜你喜欢
随机推荐
Demonstration meeting on startup and implementation scheme of swarm intelligence autonomous operation smart farm project
Multitimer V2 reconstruction version | an infinitely scalable software timer
Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
小程序知识点积累
Deeply learn the skills of parameter adjustment
APISIX jwt-auth 插件存在错误响应中泄露信息的风险公告(CVE-2022-29266)
大型互联网为什么禁止ip直连
MetaLife与ESTV建立战略合作伙伴关系并任命其首席执行官Eric Yoon为顾问
导入地址表分析(根据库文件名求出:导入函数数量、函数序号、函数名称)
cadence SPB17.4 - Active Class and Subclass
基于 TiDB 的 Apache APISIX 高可用配置中心的最佳实践
c语言---字符串+内存函数
一刷313-剑指 Offer 06. 从尾到头打印链表(e)
fatal error: torch/extension. h: No such file or directory
For examination
时序模型:长短期记忆网络(LSTM)
【开源工具分享】单片机调试助手(示波/改值/日志) - LinkScope
Fastjon2他来了,性能显著提升,还能再战十年
vim指定行注释和解注释
Multi level cache usage