shell二级菜单
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell二级菜单相关的知识,希望对你有一定的参考价值。
今天天气阴,有点儿无聊,就做了这么无趣的玩样儿。。。。。。
#!/bin/bash #Date:2017-6-20 #Version:1.0 #Author:xcn([email protected]) 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 } 奇迹出现: [[email protected] ~]# 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二级菜单的主要内容,如果未能解决你的问题,请参考以下文章