bash-exercises/recordbandwidth

11 lines
300 B
Bash
Executable File

#!/bin/sh
init="$(($(cat /sys/class/net/[ew]*/statistics/rx_bytes | paste -sd '+')))"
printf "Recording bandwidth. Press enter to stop."
read -r wait
fin="$(($(cat /sys/class/net/[ew]*/statistics/rx_bytes | paste -sd '+')))"
printf "%4sB of bandwidth used.\\n" $(numfmt --to=iec $(($fin-$init)))