bash編程之while與until循環:
while
until
#!/bin/bash
#
cat << EOF
d|D) show disk usage
m|M) show memory usage
s|S) show swap usage
q|Q) quited
EOF
read Input
until [ $Input == q -o $Input == Q ];do
case $Input in
d|D)
df -h
echo " d|D) show disk usage"
echo " m|M) show memory usage"
echo " s|S) show swap usage"
echo " q|Q) quited"
read Input
;;
m|M)
free -m | grep 'Mem'
echo " d|D) show disk usage"
echo " m|M) show memory usage"
echo " s|S) show swap usage"
echo " q|Q) quited"
read Input
;;
s|S)
free -m | grep 'Swap'
echo " d|D) show disk usage"
echo " m|M) show memory usage"
echo " s|S) show swap usage"
echo " q|Q) quited"
read Input
;;
*)
echo "Usage: {[d|D],[m|M],[s|S],[q|Q]}"
read Input
;;
esac
done