重庆思庄Oracle、Redhat认证学习论坛
标题: 模拟一个菜单的SHELL脚本 [打印本页]
作者: 王硕 时间: 2016-1-10 21:42
标题: 模拟一个菜单的SHELL脚本
[grid@node1 u01]$ cat testb2
#!/bin/bash
function diskspace {
clear
df -k
}
function whoseon {
clear
who
}
function memusage {
clear
cat /proc/meminfo
}
function menu {
clear
echo -e "\t\t\t\tSYS ADMIN MENU\n"
echo -e "\t1. display disk space"
echo -e "\t2. display logged on users"
echo -e "\t3. display memory usage"
echo -e "\t0. EXIT\n\n"
echo -en "\t\t ENTER:"
read -n 1 option
}
while [ 1 ]
do
menu
case $option in
0)
break;;
1)
diskspace;;
2)
whoseon;;
3)
memusage ;;
*)
clear
echo "SORRY";;
esac
echo -en "\n\n\t\tenter any key to CONTINUE"
read -n 1 line
done
clear
效果图: