您的位置:首页 > 运维架构 > Shell

shell实现菜单选择

2013-06-07 23:31 411 查看
output="Is today your birthay: "

echo  -e "\n"

select	menu_selections in Yes No Quit
do
case $menu_selections in
Yes) echo -e "\nHappy Birthday!\n"
;;
No)  echo -e "\nIt is someone's birthaday today...sorry it is not yours\n"
;;
Quit)echo -e "\nLater tater!\n"
break
;;
*)   echo -e "\nInvalid Answer...Please try again\n"
;;

esac
done

output变量是表示提示语,select后面跟的yes no quit可以看成一个数组,按键1选择yes,2选择no,3选择quit。达到菜单的目的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  menu select IT Linux shell