linux bash shell中case語句的實例
更新時間:2013年11月07日 17:31:09 作者:
本文介紹下,在bash shell編程中,有關case語句的一個例子,學習下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.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
相關文章
Linux bash刪除文件中含“指定內(nèi)容”的行功能示例
這篇文章主要介紹了Linux bash刪除文件中含“指定內(nèi)容”的行功能,結(jié)合具體實例形式分析了Linux bash刪除文件指定內(nèi)容的實現(xiàn)原理與相關操作技巧,需要的朋友可以參考下2017-06-06實現(xiàn)shell終端代碼分享(可用戶登錄 實現(xiàn)系統(tǒng)命令)
實現(xiàn)shell終端代碼分享,實現(xiàn)用戶登錄,系統(tǒng)命令使用,大家參考實現(xiàn)吧2013-12-12