rendered paste body#!/bin/bash# filename: l-rateexport 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 1fistring_repeat() { string="$1" times="$2" printf "%0*d\n" "$times" 0 | sed 's/0/'"$char"'/g'}rxbytes() { 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)" printf "%s\r" "$(string_repeat " " 40)" printf " RX: %8.2f KB/s, TX: %8.2f KB/s\r" $rxrate $txrate tot_rxbytes_old=$tot_rxbytes tot_txbytes_old=$tot_txbytes sleep 1done