11

用shell实现一个简单的menu(linux)

 2 years ago
source link: http://blog.colorccm.com/2020/11/02/it/shell_menu/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

用shell实现一个简单的menu(linux)

发表于2020-11-02|更新于2020-11-02|it
阅读量:4

在Linux中使用shell实现一个简单的菜单,可以用来作为运维菜单。

shell
function menu()
{
cat << EOF
------------------------------------------
|******************MENU******************|
------------------------------------------
`echo -e "\033[33m1)function1\033[0m"`
`echo -e "\033[33m2)function2\033[0m"`
`echo -e "\033[33m0)exit\033[0m"`
EOF
read -p "select function:" fun
case ${fun} in
1)
function1
menu
;;
2)
function2
menu
;;
0)
exit 0
esac
}

function function1()
{
do something
}

function function2()
{
do something
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK