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 ...
随机推荐
- CListCtrl控件使用方法总结
今天第一次用CListCtrl控件,遇到不少问题,查了许多资料,现将用到的一些东西总结如下: 以下未经说明,listctrl默认view 风格为report 相关类及处理函数 MFC:CListCtr ...
- C++ string and wstring convert
http://blog.sina.com.cn/s/blog_7632c6010100u1et.html http://www.codeproject.com/Tips/197097/Converti ...
- spring MVC中的异常统一处理
1.spring MVC中定义了一个标准的异常处理类SimpleMappingExceptionResolver 该类实现了接口HandlerExceptionResolver 2.看下SimpleM ...
- vim符号列表
Exuberant Ctags工具安装 • 软件简介 Ctags generates an index (or tag) file of language objects found in sourc ...
- By.Xpath快速定位页面元素常用方法
先看一看xpath的语法 我们将在下面的例子中使用这个 XML 文档. <?xml version="1.0" encoding="ISO-8859-1" ...
- viewFlipper 之二
main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xml ...
- PKU 1204 Word Puzzles(AC自动机)
题目大意:原题链接 给定一个字符串矩阵和待查找的单词,可以朝8个不同的方向查找,输出待查找单词第一个字母在矩阵中出现的位置和该单词被查到的方向. A~H代表8个不同的方向,A代表正北方向,其他依次以4 ...
- Spring-1-E Game(HDU 5011)解题报告及测试数据
Game Time Limit:1000MS Memory Limit:65536KB Description Here is a game for two players. The rule ...
- 关于hibernate插入数据到mysql数据库中文乱码问题的解决
要想解决这个问题就要找到问题的症结所在 1.首先将数据提交到action输出看action里的数据是不是中文乱码,结果很遗憾并不是这里的问题 2.设置数据库连接url: 3.打开mysql安装文件里的 ...
- cocos2d-x项目中如何避免增加一个cpp就必须在工程android.mk文件去添加引用
LOCAL_SRC_FILES := hellocpp/main.cpp \ ../../Classes/AppDelegate.cpp \ ../../Classes/HelloWorl ...