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\n",$1*100 }' /home/shell/cun.txt 

 

posted @ 2015-04-14 13:38  kin2321  阅读(166)  评论(0编辑  收藏  举报