方法一:用here文档和case语句建立
#!/bin/bash
while true
do
cat<<- ENDIT //<<-忽略制表符TAB
1)linux
2)xterm
3)sun
2)xterm
3)sun
4)quit
ENDIT
read choice
case "$choice" in
1)
TERM=linux
export TERM
;;
export TERM
;;
2)
TERM=xterm
export TERM
;;
export TERM
;;
3)
TERM=SUN
export TERM
;;
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)
1)
echo wyse50
break;;
break;;
2)
echo vt200
break;;
break;;
3)
echo xterm
break;;
break;;
4)
echo sun
break;;
break;;
*)
echo error choice,retry
REPLY=
;;
REPLY=
;;
esac
done
=-=-=-=-=
Powered by Blogilo