linux shell下写监控网卡流量的脚本(未完待续)

#! /bin/sh

a=`cat /sys/class/net/eth0/statistics/rx_bytes`

sleep 5

b=`cat /sys/class/net/eth0/statistics/rx_bytes`

c=`echo "$b-$a"|bc`

echo "$c"

d=`echo "scale=4;$c/1000/5"|bc`

m=`echo "scale=4;$c/1000/5"|bc|cut -d "." -f 1`

if [ -z "$m" ]; then

        e="0$d"

        echo "$e"

else

 echo "$d"

fi

你可能感兴趣的:(Linux shell)