Created
June 18, 2025 06:33
-
-
Save aznhe21/5443082b99086d7dc51c918231be2b9e to your computer and use it in GitHub Desktop.
Monitor network speed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $# -ne 1 ]]; then | |
echo "Usage: $0 <interface>" | |
ls /sys/class/net | |
exit 1 | |
fi | |
while true; do | |
rx1=$(cat "/sys/class/net/$1/statistics/rx_bytes") | |
tx1=$(cat "/sys/class/net/$1/statistics/tx_bytes") | |
sleep 1 | |
rx2=$(cat "/sys/class/net/$1/statistics/rx_bytes") | |
tx2=$(cat "/sys/class/net/$1/statistics/tx_bytes") | |
printf "\r\e[KRX: %sB/s TX: %sB/s" "$(numfmt --to=iec $((rx2 - rx1)))" "$(numfmt --to=iec $((tx2 - tx1)))" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment