1. #!/bin/bash
    2. NIC=$1
    3. echo -e " In ------ Out"
    4. while true; do
    5. OLD_IN=$(awk '$0~"'$NIC'"{print $2}' /proc/net/dev)
    6. OLD_OUT=$(awk '$0~"'$NIC'"{print $10}' /proc/net/dev)
    7. sleep 1
    8. NEW_IN=$(awk '$0~"'$NIC'"{print $2}' /proc/net/dev)
    9. NEW_OUT=$(awk '$0~"'$NIC'"{print $10}' /proc/net/dev)
    10. IN=$(printf "%.1f%s" "$((($NEW_IN-$OLD_IN)/1024))" "KB/s")
    11. OUT=$(printf "%.1f%s" "$((($NEW_OUT-$OLD_OUT)/1024))" "KB/s")
    12. echo "$IN $OUT"
    13. sleep 1
    14. done