21 lines
482 B
Bash
Executable File
21 lines
482 B
Bash
Executable File
#!/bin/sh
|
|
|
|
big="\033[11m"
|
|
reset="\033[0m"
|
|
|
|
update() {
|
|
sum=0
|
|
for arg; do
|
|
read -r i <"$arg"
|
|
sum=$((sum + i))
|
|
done
|
|
cache=/tmp/${1##*/}
|
|
[ -f "$cache" ] && read -r old <"$cache" || old=0
|
|
printf "%b" "$sum\n" >"$cache"
|
|
printf "%b" "$((sum - old))\n"
|
|
}
|
|
|
|
rx=$(update /sys/class/net/[ew]*/statistics/rx_bytes)
|
|
tx=$(update /sys/class/net/[ew]*/statistics/tx_bytes)
|
|
printf "%b%5sB %b%5sB%b" "$big$reset" "$(numfmt --to=iec "$rx")" "$big$reset" "$(numfmt --to=iec "$tx")" "\n"
|