aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2023-05-21 22:58:42 +0200
committerPatrick Spek <p.spek@tyil.nl>2023-05-21 22:58:42 +0200
commit45f2cd5e890e51332e06333e185d4ed19dc8bbd3 (patch)
tree09cded5180ea359c7468fda0cb85e164cc09829b
parent1d6bbcd2925e7e5e19e26367937db91d44d14102 (diff)
Use awk for floating point math
-rw-r--r--lib/subcommands/sysinfo.bash12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/subcommands/sysinfo.bash b/lib/subcommands/sysinfo.bash
index fcfbff5..5514c43 100644
--- a/lib/subcommands/sysinfo.bash
+++ b/lib/subcommands/sysinfo.bash
@@ -65,12 +65,12 @@ subcommand() {
done
# Print fun little extras
- printf "%-15s %dGi / %dGi\n" "memory" \
- "$(( memory_used / 1024 / 1024 ))" \
- "$(( memory_total / 1024 / 1024 ))"
- printf "%-15s %dGb / %dGb\n" "storage" \
- "$(( storage_used / 1024 / 1024 ))" \
- "$(( storage_total / 1024 / 1024 ))"
+ printf "%-15s %0.1fGi / %0.1fGi\n" "memory" \
+ "$(awk '{ print($1 / 1024 / 1024) }' <<< $memory_used)" \
+ "$(awk '{ print($1 / 1024 / 1024) }' <<< $memory_total)"
+ printf "%-15s %0.1fGb / %0.1fGb\n" "storage" \
+ "$(awk '{ print($1 / 1024 / 1024) }' <<< $storage_used)" \
+ "$(awk '{ print($1 / 1024 / 1024) }' <<< $storage_total)"
printf "%-15s %0.2f %0.2f %0.2f\n" "load" \
"$load_1" \
"$load_5" \