rendered paste body#!/bin/bashexport LC_ALL=Ciface="$1"if [[ -z "$iface" ]]; then echo "Interface not specified: using eth0" iface="eth0"fiif ! /sbin/ifconfig >/dev/null 2>/dev/null "$iface"; then echo "Invalid interface" exit 1firxbytes() { iface="$1" /sbin/ifconfig "$iface" | awk '/RX bytes/ { split($2, a, ":"); print a[2] }'}txbytes() { iface="$1" /sbin/ifconfig "$iface" | awk '/TX bytes/ { split($6, a, ":"); print a[2] }'}tot_rxbytes_old="$(rxbytes "$iface")"tot_txbytes_old="$(txbytes "$iface")"sleep 1while true; do tot_rxbytes="$(rxbytes "$iface")" tot_txbytes="$(txbytes "$iface")" rxrate="$(echo "scale=2; ($tot_rxbytes - $tot_rxbytes_old)/1024" | bc)" txrate="$(echo "scale=2; ($tot_txbytes - $tot_txbytes_old)/1024" | bc)" echo "rx rate: $rxrate KB/s, tx rate: $txrate KB/s" tot_rxbytes_old=$tot_rxbytes tot_txbytes_old=$tot_txbytes sleep 1done