小脚本:
执行效果 显示一个菜单 当输出菜单上给出的键后,执行相应的动作
即 当用户输出d 显示 show disk usages. 当然这也可以真的显示disk使用情况,只是加入的命令的不同,哈哈,,,这个是个人自己编写的,,看老师给出的题目。
[root@localhost script]# cat choice.sh
#!/bin/bash
echo "(d|D) shwo disk usages."
echo "(m|M) show memory usages."
echo "(s|S) show swap usages."
echo "(qQ) quit"
echo "(p) print this menu"
read -p "input options: " INSOME
while [ $INSOME != 'quit' ]; do
case $INSOME in
[Dd])
echo " show disk ussage"
read -p "input options: " INSOME;;
[mM])
echo "show memory usage"
read -p "input options: " INSOME;;
[sS])
echo "show swap usages"
read -p "input options: " INSOME;;
[qQ])
echo "quiting..."
exit 0;;
p)
echo "(d|D) shwo disk usages."
echo "(m|M) show memory usages."
echo "(s|S) show swap usages."
echo "(qQ) quit"
read -p "input options: " INSOME;;
*)
echo "Unknown character."
read -p "input options: " INSOME;;
esac
done
[root@localhost script]#