当前位置:网站首页>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
- 现在做自媒体能赚钱吗?看完这篇文章你就明白了
- MySQL Cluster Mode and application scenario
- Special analysis of China's digital technology in 2022
- Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
- 负载均衡器
- The principle and common methods of multithreading and the difference between thread and runnable
- Codejock Suite Pro v20.3.0
- 导入地址表分析(根据库文件名求出:导入函数数量、函数序号、函数名称)
猜你喜欢

WPS brand was upgraded to focus on China. The other two domestic software were banned from going abroad with a low profile

APISIX jwt-auth 插件存在错误响应中泄露信息的风险公告(CVE-2022-29266)

Sorting and replying to questions related to transformer

一刷314-剑指 Offer 09. 用两个栈实现队列(e)

CVPR 2022 quality paper sharing

The principle and common methods of multithreading and the difference between thread and runnable

大厂技术实现 | 行业解决方案系列教程

Spark 算子之distinct使用

CVPR 2022 优质论文分享

【AI周报】英伟达用AI设计芯片;不完美的Transformer要克服自注意力的理论缺陷
随机推荐
cadence SPB17. 4 - Active Class and Subclass
删除字符串中出现次数最少的字符
Use bitnami PostgreSQL docker image to quickly set up stream replication clusters
cadence SPB17.4 - Active Class and Subclass
PHP 的运算符
Why is IP direct connection prohibited in large-scale Internet
MetaLife与ESTV建立战略合作伙伴关系并任命其首席执行官Eric Yoon为顾问
网站压测工具Apache-ab,webbench,Apache-Jemeter
时序模型:长短期记忆网络(LSTM)
php函数
基于 TiDB 的 Apache APISIX 高可用配置中心的最佳实践
布隆过滤器在亿级流量电商系统的应用
开源项目推荐:3D点云处理软件ParaView,基于Qt和VTK
pgpool-II 4.3 中文手册 - 入门教程
MySQL Cluster Mode and application scenario
Go并发和通道
Upgrade MySQL 5.1 to 5.611
vim指定行注释和解注释
What if the package cannot be found
时序模型:门控循环单元网络(GRU)