shell实现菜单选择

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。达到菜单的目的。

你可能感兴趣的:(Linux)