linux bash shell中case語(yǔ)句的實(shí)例
更新時(shí)間:2013年11月07日 17:31:09 作者:
本文介紹下,在bash shell編程中,有關(guān)case語(yǔ)句的一個(gè)例子,學(xué)習(xí)下case語(yǔ)句的用法,有需要的朋友參考下
bash case語(yǔ)句的例子。
分享一段bash shell代碼,對(duì)于學(xué)習(xí)bash的同學(xué)理解case語(yǔ)句的用法,會(huì)有幫助。
例子:
復(fù)制代碼 代碼如下:
#!/bin/bash
##
# Program:
# File operation
# 1.) Open file 2.) Display file 3.) Edit file 4.) Delete file
# site: www.dbjr.com.cn
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
相關(guān)文章
Linux中make安裝與卸載及注意事項(xiàng)小結(jié)
這篇文章主要介紹了Linux中make安裝與卸載及注意事項(xiàng),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2023-12-12Linux bash刪除文件中含“指定內(nèi)容”的行功能示例
這篇文章主要介紹了Linux bash刪除文件中含“指定內(nèi)容”的行功能,結(jié)合具體實(shí)例形式分析了Linux bash刪除文件指定內(nèi)容的實(shí)現(xiàn)原理與相關(guān)操作技巧,需要的朋友可以參考下2017-06-06實(shí)現(xiàn)shell終端代碼分享(可用戶登錄 實(shí)現(xiàn)系統(tǒng)命令)
實(shí)現(xiàn)shell終端代碼分享,實(shí)現(xiàn)用戶登錄,系統(tǒng)命令使用,大家參考實(shí)現(xiàn)吧2013-12-12關(guān)于SSH 遠(yuǎn)程執(zhí)行命令你要知道的二三事
SSH 是 Linux 下進(jìn)行遠(yuǎn)程連接的基本工具,但是如果僅僅用它來(lái)登錄那可是太浪費(fèi)啦!SSH 命令可是完成遠(yuǎn)程操作的神器啊,下面這篇文章主要給大家介紹了關(guān)于SSH 遠(yuǎn)程執(zhí)行命令的一些相關(guān)資料,需要的朋友可以參考下。2017-07-07