shell脚本中case select 的使用
#!/bin/bash
# case
echo "1.Install PHP"
echo "2.Install Mysql"
echo "3.Install Nginx"
read -p "please input your digit:" digit
case "$digit" in
"1" )
echo "Install PHP"
#输出两个分号
;;
"2" )
echo "Install Mysql"
;;
"3" )
echo "Install Nginx"
;;
* )
#其它输入
echo "Error"
;;
esac
运行结果
# sh case.sh
1.Install PHP
2.Install Mysql
3.Install Nginx
please input your digit:1
Install PHP
结合select做选择菜单。
#! /bin/bash
# case
PS3="Select your digit:"
select i in "Install PHP" "Install Mysql" "Install Nginx"
do
case $i in
"Install PHP" )
echo "Install PHP"
#输出两个分号
;;
"Install Mysql" )
echo "Install Mysql"
;;
"Install Nginx" )
echo "Install Nginx"
;;
* )
#其它输入
echo "Error"
;;
esac
done
执行的时候,必须用bash来执行。
# /bin/bash case.sh
1) Install PHP
2) Install Mysql
3) Install Nginx
Select your digit:1
Install PHP
Select your digit:2
Install Mysql
Select your digit:3
Install Nginx
Select your digit:4
Error
Select your digit:^C
shell脚本中case select 的使用的更多相关文章
- [转]Shell脚本中获取SELECT结果值的方法
http://blog.itpub.net/13885898/viewspace-1670297/ 有时候我们可能会需要在Shell脚本中执行SELECT语句,并将结果赋值给一个变量,对于这样的情形, ...
- shell脚本中case的用法
shell脚本中case选择语句可以结合read指令实现比较好的交互应答操作,case接收到read指令传入的一个或多个参数,然后case根据参数做选择操作. case的语法如下 case $char ...
- Shell脚本中获取select值
最近做一个数据清理,根据行号清理,所以需要查出这个行的最大最小值出来进行删除,如果靠手动每次去查,太麻烦所以就用在sh脚本当中执行SELECT语句,并将结果赋值给一个变量. sh脚本如下 #! /bi ...
- shell脚本中case /*的作用
如下语句 case $0 in /*) ;; *) ;; /*在这里的作用就是绝对路径的意思
- centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 第三十六节课
centos shell脚本编程2 if 判断 case判断 shell脚本中的循环 for while shell中的函数 break continue test 命令 ...
- shell脚本中select循环语句用法
shell脚本中select循环语句 1. 脚本中select的语法格式 select VAR in LIST do command1 command2 ... ... commandN done s ...
- Shell脚本中的逻辑判断、文件目录属性判断、if的特殊用法、case判断
1.Shell脚本中的逻辑判断 格式1:if 条件 ; then 语句; fi格式2:if 条件; then 语句; else 语句; fi格式3:if …; then … ;elif …; then ...
- shell脚本中的逻辑判断、文件目录属性判断、if特殊用法、case判断
7月12日任务 20.5 shell脚本中的逻辑判断20.6 文件目录属性判断20.7 if特殊用法20.8/20.9 case判断 20.5 shell脚本中的逻辑判断 逻辑判断在shell中随处可 ...
- Linux centosVMware shell脚本中的逻辑判断、文件目录属性判断、if特殊用法、case判断
一.shell脚本中的逻辑判断 格式1:if 条件 ; then 语句; fi 格式2:if 条件; then 语句; else 语句; fi 格式3:if …; then … ;elif …; th ...
随机推荐
- codechef : Marbles 题解
版权声明:本文作者靖心,靖空间地址:http://blog.csdn.net/kenden23/,未经本作者同意不得转载. https://blog.csdn.net/kenden23/article ...
- Java集合—Queue(转载)
Queue用于模拟队列这种数据结构,队列通常是指“先进先出”(FIFO)的容器.新元素插入(offer)到队列的尾部,访问元素(poll)操作会返回队列头部的元素.通常,队列不允许随机访问队列中的元素 ...
- jquery Chosen使用
1,首先去http://harvesthq.github.io/chosen/下载插件. 2,在网页中加入下面的文件. <link rel="stylesheet" href ...
- kettle配置命名参数
bat 调度文件如下 cd D:/Program Files/kettle700/data-integrationKitchen.bat /rep repository /dir /TEST /job ...
- 项目实战:Mahout构建图书推荐系统
前言 本文是Mahout实现推荐系统的又一案例,用Mahout构建图书推荐系统.与之前的两篇文章,思路上面类似,侧重点在于图书的属性如何利用.本文的数据在自于Amazon网站,由爬虫抓取获得. 目录 ...
- HttpClient使用详解(转)
http://blog.csdn.net/wangpeng047/article/details/19624529
- java jdom 解析CDATA内容
package com; import java.io.IOException; import java.io.StringReader; import java.util.List; import ...
- 解决wordcloud导出图片不清楚
使用WordCloud生成词云图片 本文详细介绍参考自:https://www.jianshu.com/p/fdd0acccf1c5 wordcloud开源项目:https://github.com/ ...
- hdu5716
地址: 题目: 带可选字符的多字符串匹配 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...
- 2017 Multi-University Training Contest - Team 1 03Colorful Tree
地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6035 题面: Colorful Tree Time Limit: 6000/3000 MS ( ...