From 0b8685b836fb3cc034857438bf87076fa39af1a1 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 14 Aug 2023 12:50:14 +0200 Subject: [saf] remove bc dependency --- bin/common/saf | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'bin/common/saf') diff --git a/bin/common/saf b/bin/common/saf index 9e31c68..2936346 100755 --- a/bin/common/saf +++ b/bin/common/saf @@ -8,10 +8,11 @@ reset="$(printf '\033[0m')" load () { - for time in $(uptime | cut -f3- -d',' | cut -f2 -d':' | tr ',' ' ') - do - percent="$(echo "$time*100/$(nproc)" | bc)" - echo "${percent:-0}%" + # take everything after 'load average: ' then remove '0.' or '.' or ',' + # from output, this multiplies by hundred, so we can divide an integer + # instead of a fraction (which dash can't do) + for time in $(uptime | sed -e 's/^.*load average://' -e 's/0\?\.\|,//g') + do printf "%s%%\n" "$((time/$(nproc)))" done | xargs } -- cgit v1.2.3