建立菜单

方法一:用here文档和case语句建立

#!/bin/bash

while true

do

cat<<- ENDIT //<<-忽略制表符TAB

1)linux
2)xterm
3)sun
4)quit

ENDIT
read choice
case "$choice" in
1)

TERM=linux
export TERM
;;

2)

TERM=xterm
export TERM
;;

3)

TERM=SUN
export TERM
;;

4)

  break;;

esac

done

方法二:用select循环命令和case命令

1)如果要退出select循环,可以用break
2)如果REPLY变量为空,将会重新显示菜单

#!/bin/bash

PS3="Please choose terminal type[1-4] : "
select choice in wyse50 vt200 xterm sun
do

case $REPLY in
1)
echo wyse50
break;;
2)
echo vt200
break;;
3)
echo xterm
break;;
4)
echo sun
break;;
*)
echo error choice,retry
REPLY=
;;
esac

done 

 

=-=-=-=-=
Powered by Blogilo

posted on 2015-06-22 22:21  chenxiaopang  阅读(169)  评论(0编辑  收藏  举报

导航