replace bc usage with an awk floating point math limiting to 2 decimal places

This commit is contained in:
Emma 2024-01-30 14:14:10 -08:00
parent 509c2c114f
commit 43ee6f2cb0

View file

@ -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)"
fi
echo "$result ${SIZE[$size]}"
@ -103,12 +103,6 @@ main() {
interval_update=0
fi
if ! command -v bc &> /dev/null
then
echo "command bc could not be found!"
exit 1
fi
while true; do
if ((counter == 0)); then
counter=60