cpu、内存、磁盘

例一:内存使用率

#!/bin/bash
total=$(free -m|grep Mem|awk '{print $2}')
used=$(free -m|grep Mem|awk '{print $3}')
echo "$used/$total"|bc -l >> /home/shell/cun.txt

 可以读取再打印出来

awk '{print $1*100 }' /home/shell/cun.txt  

 保留两位小数

awk '{printf "%.2f
",$1*100 }' /home/shell/cun.txt 
原文地址:https://www.cnblogs.com/bluewelkin/p/4424654.html