From 9858bf1d3bb50a14349782aa4b3b17261ff730c8 Mon Sep 17 00:00:00 2001 From: Vinicius Mello Date: Fri, 15 Oct 2021 14:34:36 -0300 Subject: [PATCH] improve readability of results text Improve the readability of results by aligning numbers and units in the same column. Also improve aligning of 3 digit numbers. --- dnstest.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dnstest.sh b/dnstest.sh index 145efc5..76ab6e4 100755 --- a/dnstest.sh +++ b/dnstest.sh @@ -30,12 +30,12 @@ DOMAINS2TEST="www.google.com amazon.com facebook.com www.youtube.com www.reddit. totaldomains=0 -printf "%-18s" "" +printf "%-22s" "" for d in $DOMAINS2TEST; do totaldomains=$((totaldomains + 1)) - printf "%-8s" "test$totaldomains" + printf "%-9s" "test$totaldomains" done -printf "%-8s" "Average" + printf "%-9s" "Average" echo "" @@ -54,12 +54,12 @@ for p in $NAMESERVERS $PROVIDERS; do ttime=1 fi - printf "%-8s" "$ttime ms" + printf "%6d ms" "$ttime" ftime=$((ftime + ttime)) done avg=`bc -lq <<< "scale=2; $ftime/$totaldomains"` - echo " $avg" + printf " %8.2f\n" "$avg" done