#!/bin/bash I="${1}" NIC="eth0" TX_Bytes() { /sbin/ifconfig "${NIC}"|egrep 'RX bytes'|awk '{print $2}'|cut -d':' -f2 } start_bandwidth_usage=$(TX_Bytes) sleep "${1}" new_bandwidth_usage=$(TX_Bytes) speed=$(($(($(($new_bandwidth_usage - $start_bandwidth_usage)) / $I)) / 1024)) echo "${speed} KiB/s average in the past ${I} seconds"