linux bash shell中case语句的实例

发布时间:2022-04-19 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了linux bash shell中case语句的实例脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

bash case语句的例子。

分享一段bash shell代码,对于学习bash的同学理解case语句的用法,会有帮助。

例子:

复制代码 代码如下:

#!/bin/bash
##
# 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语句的实例所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:bashbashshell