diff --git a/bwrate b/bwrate index acb982b..257e7eb 100755 --- a/bwrate +++ b/bwrate @@ -1,27 +1,26 @@ #!/usr/bin/env bash -TIMESPAN=1 +timespan=1 -if [ -z $1 ]; then - echo "Error: no device specified" +[[ -z "$1" ]] && { + printf '%s\n' 'Error: no device specified' exit 1 -fi -if [ ! -d /sys/class/net/$1 ]; then - echo "No such device: $1" +} +[[ ! -d "/sys/class/net/$1" ]] && { + printf '%s\n' "No such device: $1" exit 1 -fi +} -BR1=`cat /sys/class/net/$1/statistics/rx_bytes` -BT1=`cat /sys/class/net/$1/statistics/tx_bytes` +br1=$(