linux bash shell中case语句的实例
本文介绍下,在bash shell编程中,有关case语句的一个例子,学习下case语句的用法,有需要的朋友参考下。
本文转自:http://www.jbxue.com/article/13377.html
bash case语句的例子。
分享一段bash shell代码,对于学习bash的同学理解case语句的用法,会有帮助。
例子:
## www.jbxue.com
# Program:
# File operation
# 1.) Open file 2.) Display file 3.) Edit file 4.) Delete file
# site: WWW.JB51.NET
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
echo "---------------------------------"
echo "List of item to operate file -"
echo "---------------------------------"
echo "1). Open a file -"
echo "2). Display a file -"
echo "3). Edit a file -"
echo "4). Delete a file -"
echo "---------------------------------"
read select
case $select in
1)
echo "do open file operation"
2)
echo "do display a file operation"
3)
echo "do edit a file operation"
4)
echo "do delete a file operation"
*)
echo "There is nothing to do!"
exit 1
esac
linux bash shell中case语句的实例的更多相关文章
- (二)shell中case语句、程序传参、while
2.2.6.1.case语句(1)shell中的case语句和C语言中的switch case语句作用一样,格式有差异(2)shell中的case语句天生没有break,也不需要break,和C语言中 ...
- linux bash shell中,单引号、 双引号,反引号(``)的区别及各种括号的区别
一.单引号和双引号 首先,单引号和双引号,都是为了解决中间有空格的问题. 因为空格在Linux中时作为一个很典型的分隔符,比如string1=this is astring,这样执行就会报错.为了避免 ...
- bash shell中测试命令
bash shell中测试命令 test命令提供了if-than语句中测试不同条件的途径.如果test命令中列出的条件成立,test命令就会退出并返回退出状态吗0 .这样if-than语句就与其他编程 ...
- shell的case语句简述(shell的流控制)
shell流控制:http://www.cnblogs.com/yunjiaofeifei/archive/2012/06/12/2546208.html 1.if then else 语句 if t ...
- 【Linux】linux bash shell之变量替换::=句法、=句法、:-句法、-句法、=?句法、?句法、:+句法、+句法
linux bash shell之变量替换::=句法.=句法.:-句法.-句法.=?句法.?句法.:+句法.+句法 linux bash shell之变量替换::=句法.=句法.:-句法.-句法. ...
- linux BASH shell设置字体与背景颜色
linux BASH shell下设置字体及背景颜色的方法. BASH shell下设置字体及背景颜色 echo -e "\e[31mtest\e[41m" \e[30m 将字 ...
- Bash shell中的位置参数$#,$*,$@,$0,$1,$2...及特殊参数$?,$-等的含义
http://hi.baidu.com/lolorosa/blog/item/5775a608bd670d33b0351da7.html $# 是传给脚本的参数个数 $@ 是传给脚本的所有参数的列表 ...
- [转] linux下shell中使用上下键翻出历史命名时出现^[[A^[[A^[[A^[[B^[[B的问题解决,Linux使用退格键时出现^H解决方法
[From] https://www.zmrbk.com/post-2030.html https://blog.csdn.net/suifengshiyu/article/details/40952 ...
- Shell 编程 case语句
本篇主要写一些shell脚本case语句的使用. 字符判断 #!/bin/bash read -p "请输入一个字符:" char case $char in [a-z]|[A-Z ...
随机推荐
- Java多线程---------同步与死锁:synchronized;等待与唤醒:wait、notify、notifyAll;生命周期
1.问题的引出 class MyThread implements Runnable{ private int ticket = 5 ; // 假设一共有5张票 public void run(){ ...
- [转]Unity批量制作预制物体Prefab
http://www.u3dblog.com/?p=441 有时候场景中一大批物体都需要制作成预制物体,但是unity只能手动一个一个的创建,感觉非常的蹩脚,下面一个编辑器类的方法解决你的麻烦. st ...
- android studio常用快捷键(不断补充)
1.查找类 ctrl + n 2.查找全局文件 双击shift 3.返回上一次编辑的地方 ctrl + shift + backspace 4.代码格式化ctrl + alt + L 5.查看类的结 ...
- [ES6] 23. Rest Parameters & Spread Parameters
Rest Parameters: In ES5, when you don't know how many paramters will be passed in, you can use argum ...
- [Javascript] The Array filter method
One very common operation in programming is to iterate through an Array's contents, apply a test fun ...
- Percona-toolkit的安装和配置-杨建荣的学习笔记
http://blog.itpub.net/23718752/viewspace-2091818/#rd
- hdu1753java(大数相加)---BigDecimal类
大明A+B Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submissi ...
- Docker container network configuration
http://xmodulo.com/networking-between-docker-containers.html How to set up networking between Docker ...
- Java动态绑定
1. 动态绑定 将一个方法调用同一个方法主体关联起来被称作绑定. 在运行时根据对象的类型进行绑定,叫做后期绑定或运行时绑定.Java中除了static方法和final 例如,下面定义了一个Shape类 ...
- dumpbin工具的使用
当我们需要查看一个dll或exe文件中的包含的函数或是依赖的函数之类的信息,可以使用Visual Studio自带的工具dumpbin来实现,使用方法为: 1/ 启动Visual Studio 命令行 ...