当前位置:首页 / 编程技术 / 运营维护 / linux bash shell中case语句的实例
linux bash shell中case语句的实例
发布时间:2022/07/10来源:编程网

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.gimoo.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
分享到:
免责声明:本文仅代表文章作者的个人观点,与本站无关,请读者仅作参考,并自行核实相关内容。文章内容来源于网络,版权归原作者所有,如有侵权请与我们联系,我们将及时删除。
资讯推荐
热门最新
精品工具
全部评论(0)
剩余输入数量90/90
暂无任何评论,欢迎留下你的想法
你可能感兴趣的资讯
换一批