Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!
Guest

Untitled

By: a guest on Nov 8th, 2012  |  syntax: None  |  size: 0.39 KB  |  hits: 30  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. IF=eth0
  2.  
  3. if [ ! -z $1 ]; then IF=$1; fi
  4.  
  5. D=$(grep $IF /proc/net/dev)
  6. RX=$(echo $D | awk  '{print $2}')
  7. TX=$(echo $D | awk  '{print $10}')
  8.  
  9. if [ "$2" != "" -a "$3" != "" ]; then
  10.   RXD=$(($RX-$2))
  11.   TXD=$(($TX-$3))
  12.   RXDK=$(echo "scale=2;$RXD/1024" | bc )" Kb/s"
  13.   TXDK=$(echo "scale=2;$TXD/1024" | bc )" Kb/s"
  14.   echo -ne "D: $RXDK     | U: $TXDK      \r"
  15. fi;
  16. sleep 1;
  17. $0 $IF $RX $TX