#!/bin/bash
if [ $# -ne 1 ];then
dev="enp2s0"
else
dev=$1
fi
while :
do
RX1=`/sbin/ifconfig $dev |awk -F " " 'NR==8{print $2}'|sed -s "s/bytes://g"`
TX1=`/sbin/ifconfig $dev |awk -F " " 'NR==8{print $6}'|sed -s "s/bytes://g"`
sleep 1
RX2=`/sbin/ifconfig $dev |awk -F " " 'NR==8{print $2}'|sed -s "s/bytes://g"`
TX2=`/sbin/ifconfig $dev |awk -F " " 'NR==8{print $6}'|sed -s "s/bytes://g"`
#echo "RX2 is $RX2"
#echo "TX2 is $TX2"
((RX=RX2-RX1))
((TX=TX2-TX1))
#echo "RX is $RX"
#echo "TX is $TX"
RKBPS=`echo $RX |awk '{print $1/1024 "KB/S"}'`
TKBPS=`echo $TX |awk '{print $1/1024 "KB/S"}'`
#clear
echo -e " 33[31mRX=$RKBPS TX=$TKBPS 33[0m"
echo `/sbin/ifconfig $dev |grep "byte"`
done