From beb6085ad78e4691879d0911897e71ffd3543d64 Mon Sep 17 00:00:00 2001 From: Adrien Kara Date: Sat, 7 Jan 2023 18:36:14 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(#165):=20is=20no=20longer=20?= =?UTF-8?q?based=20on=20word=20matching?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Kara --- scripts/ram_info.sh | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/scripts/ram_info.sh b/scripts/ram_info.sh index 97d61b6..ab983d5 100755 --- a/scripts/ram_info.sh +++ b/scripts/ram_info.sh @@ -9,20 +9,11 @@ get_percent() { case $(uname -s) in Linux) - total_mem_gb=$(free -g | awk '/^Mem/ {print $2}') - used_mem=$(free -g | awk '/^Mem/ {print $3}') - total_mem=$(free -h | awk '/^Mem/ {print $2}') - if (( $total_mem_gb == 0)); then - memory_usage=$(free -m | awk '/^Mem/ {print $3}') - total_mem_mb=$(free -m | awk '/^Mem/ {print $2}') - echo $memory_usage\M\B/$total_mem_mb\M\B - elif (( $used_mem == 0 )); then - memory_usage=$(free -m | awk '/^Mem/ {print $3}') - echo $memory_usage\M\B/$total_mem_gb\G\B - else - memory_usage=$(free -g | awk '/^Mem/ {print $3}') - echo $memory_usage\G\B/$total_mem_gb\G\B - fi + usage="$(free -h | awk 'NR==2 {print $3}')" + total="$(free -h | awk 'NR==2 {print $2}')" + formated="${usage}/${total}" + + echo "${formated//i/B}" ;; Darwin)