根据用户的输入,显示系统的内存,硬盘及交换空间的使用情况

#!/bin/bash
#
function menu(){
cat << EOF
d|D) show disk usages
m|M) show memory usages
s|S) show swap usages
q|Q) quit.
EOF
}
while :;do
menu
read -p "Your choice: " choice
case $choice in
d|D)
df -lh
;;
m|M)
free -m | grep "^Mem"
;;
s|S)
free -m | grep "Swap"
;;
q|Q)
break
;;
*)
echo -e "33[32mChoose the wrong re-selection33[0m"
continue
;;
esac
done

原文地址:https://www.cnblogs.com/sjie0224/p/6840916.html