#!/bin/awk -f BEGIN { while ("for f in /sys/class/net/[ew]*; do paste $f/statistics/[rt]x_bytes; done" | getline) { d+=$1; u+=$2; } getline < "/tmp/test"; od=$1; ou=$2; ot=$3; getline < "/proc/uptime"; t=$1; print d,u,t > "/tmp/test"; t=t-ot; if (!t) t=1; printf "%.1f/%.1f MB/s\n", ((d-od)/1000000)/t, ((u-ou)/1000000)/t; }