码迷,mamicode.com
首页 > 系统相关 > 详细

shell脚本实现命令行多级菜单(无具体功能)

时间:2015-11-23 19:09:38      阅读:650      评论:0      收藏:0      [点我收藏+]

标签:shell脚本

#!/bin/bash

#auth chentp0601

#date 20151123

function menu()

{

clear

cat <<EOF

#this is base menu

1.[install lamp]

2.[install lnmp]

3.[exit]

EOF

read -p "please input 1-3:" list

     case $list in

        "1")

while true 

do 

menu_lamp 

done

        ;;

        "2")

while true 

do 

menu_lnmp 

done

        ;;

        "3")

        echo -e "exiting . . .\n";

        sleep 1

        exit 0

        ;;

        *)

        continue

        ;;

      esac

}


function menu_lamp()

{

clear

cat <<EOF

#this is lamp menue

1.[install apache]

2.[install mysql]

3.[install php]

4.[back]

EOF

read -p "please input 1-3:" list1

case $list1 in

"1")

echo -e "installing apache\n"

sleep 2

continue

;;

"2")

echo -e "installing mysql\n"

sleep 2

;;

"3")

echo -e "installing php\n"

sleep 2

;;

"4")

break

;;

*)

continue

;;

esac

}



function menu_lnmp()

{

clear

cat <<EOF

#this is lnmp menu

1.[install nginx]

2.[install mysql]

3.[install php]

4.[back]

EOF

read -p "please input 1-4:" list2

case $list2 in

"1")

echo -e "installing nginx\n"

sleep 2

continue

;;

"2")

echo -e "installing mysql\n"

sleep 2

;;

"3")

echo -e "installing php\n"

sleep 2

;;

"4")

break

;;

*)

continue

;;

esac

}


while true

do

menu

done


本文出自 “前进吧菜鸟” 博客,请务必保留此出处http://chentp.blog.51cto.com/10638759/1716086

shell脚本实现命令行多级菜单(无具体功能)

标签:shell脚本

原文地址:http://chentp.blog.51cto.com/10638759/1716086

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!