From 43ee6f2cb0d62ea8804081117c246ff02c220720 Mon Sep 17 00:00:00 2001 From: Emma Date: Tue, 30 Jan 2024 14:14:10 -0800 Subject: [PATCH] replace bc usage with an awk floating point math limiting to 2 decimal places --- scripts/network_bandwidth.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/scripts/network_bandwidth.sh b/scripts/network_bandwidth.sh index b381e24..bad4138 100755 --- a/scripts/network_bandwidth.sh +++ b/scripts/network_bandwidth.sh @@ -85,7 +85,7 @@ bandwidth_to_unit() { local result="0.00" if (($1 != 0)); then - result="$(bc <<<"scale=2; $1 / $size")" + result="$(awk -v a="$1" -v b="$size" 'BEGIN { printf "%.2f\n", a / b }' /dev/null - then - echo "command bc could not be found!" - exit 1 - fi - while true; do if ((counter == 0)); then counter=60