这种脚本一种是按照下面这种比较笨的方法写,还有一种是可以按照case方式来写
这里仅当做一个初始化的模板供参考
#! /bin/bash
clear
echo "-----------------------menu----------------"
echo "1)show time"
echo "2)CPU load"
echo "3)Memory Free"
echo "0)Exit"
echo "-------------------------------------------"
echo -n "Entern you chose[0-3]:"
read NUM
if [ ${NUM} -lt 0 -o ${NUM} -gt 3 ]
then
echo "This is not between 0-3"
else
if [ "${NUM}" == "1" ]
then
echo "`date +%T`"
else
if [ "${NUM}" == "2" ]
then
echo "`uptime | awk '{print $8}'`"
else
if [ "${NUM}" == "3" ]
then
echo "`free | awk '$1=="Mem:"{print $4}'`"
else
exit 0
fi
fi
fi
fi
本文转自 yuri_cto 51CTO博客,原文链接:http://blog.51cto.com/laobaiv1/1840856,如需转载请自行联系原作者