标签:shell二级菜单
今天天气阴,有点儿无聊,就做了这么无趣的玩样儿。。。。。。
#!/bin/bash #Date:2017-6-20 #Version:1.0 #Author:xcn(baishuchao@yeah.net) menu (){ cat <<END 1.[install lamp] 2.[install lnmp] 3.[exit] pls input the num you want: END read -t 15 a } menu1 (){ cat <<END 1.[APCHE] 2.[MYSQL] 3.[PHP] 4.[BACK] Pls input the lamp menu num you want: ************************************* END read num1 } menu2 (){ cat <<END 1.[NGINX] 2.[MYSQL] 3.[PHP] 4.[BACK] Pls input the lnmp menu num you want: ************************************** END read num2 } #######################[ menu1 ]############################ menu [ $a -eq 1 ] && { clear menu1 [ $num1 -eq 1 ] && { echo "installing apache" sleep 3 echo "install is apacheed" menu1 } [ $num1 -eq 2 ] && { echo "installing mysql" sleep 3 echo "install is mysqled" menu1 } [ $num1 -eq 3 ] && { echo "installing php" sleep 3 echo "install is php" menu1 } [ $num1 -eq 4 ] && { echo "return to previous menu" menu } } ####################[ menu2 ]######################################## [ $a -eq 2 ] && { clear menu2 [ $num2 -eq 1 ] && { echo "installing nginx" sleep 3 echo "install is nginx" menu2 } [ $num2 -eq 2 ] && { echo "installing mysql" sleep 3 echo "install is mysqled" menu2 } [ $num2 -eq 3 ] && { echo "installing php" sleep 3 echo "install is php" menu2 } [ $num2 -eq 4 ] && { echo "return to previous menu" menu } } [ $a -eq 3 ] && { echo "baybay" exit } 奇迹出现: [root@XCN ~]# sh menu.sh 1.[install lamp] 2.[install lnmp] 3.[exit] pls input the num you want: 1 1.[APCHE] 2.[MYSQL] 3.[PHP] 4.[BACK] Pls input the lamp menu num you want: ************************************* 2 installing mysql install is mysqled 1.[APCHE] 2.[MYSQL] 3.[PHP] 4.[BACK] Pls input the lamp menu num you want: *************************************
本文出自 “小菜鸟” 博客,请务必保留此出处http://baishuchao.blog.51cto.com/12918589/1941361
标签:shell二级菜单
原文地址:http://baishuchao.blog.51cto.com/12918589/1941361