Skip to content

Commit

Permalink
replace bc usage with an awk floating point math limiting to 2 decima…
Browse files Browse the repository at this point in the history
…l places
  • Loading branch information
emmagamma committed Jan 30, 2024
1 parent 509c2c1 commit 43ee6f2
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions scripts/network_bandwidth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]}"
Expand All @@ -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
Expand Down

0 comments on commit 43ee6f2

Please sign in to comment.