linux bash shell中case语句的实例
2013-11-07 21:38
591 查看
本文介绍下,在bash shell编程中,有关case语句的一个例子,学习下case语句的用法,有需要的朋友参考下。
本文转自:http://www.jbxue.com/article/13377.html
bash case语句的例子。
分享一段bash shell代码,对于学习bash的同学理解case语句的用法,会有帮助。
例子:
复制代码代码如下:
#!/bin/bash
## 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
本文转自:http://www.jbxue.com/article/13377.html
bash case语句的例子。
分享一段bash shell代码,对于学习bash的同学理解case语句的用法,会有帮助。
例子:
复制代码代码如下:
#!/bin/bash
## 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语句的实例
- linux bash shell中case语句的实例
- linux bash shell中case语句的实例
- Linux Bash Shell学习(十一):流程控制——case
- linux-shell中case与select语句
- Linux基础之bash脚本编程进阶篇-选择执行语句(if,case)
- Linux-shell脚本-if语句/case语句
- leeboy的linux学习十五 shell中条件测试和简单的条件语句实例
- shell中的case语句实例介绍
- Linux下shell中的case循环语句
- linux bash shell.sh编程实例
- linux下Bash编程case语句及编写脚本(八)
- Shell 脚本之循环语句(for,while,until)以及case,select,break,continue实例详解
- 10个 Linux/Unix下 Bash 和 KSH shell 的作业控制实例
- 27_Shell语言――――case语句、bash如何与用户进行交互(case、read)
- 【Linux】中shell脚本语法篇之条件语句和循环语句
- Linux操作系统基础解析之(七)——Bash(Shell)基础知识(3)
- linux命令练习:case选择结构语句练习
- shell基础及流程控制语句之一case判断
- Linux学习之case语句