From 98e44bbaa897f4745ded973eb5c5c197e928588f Mon Sep 17 00:00:00 2001 From: Liam <33645555+lj3954@users.noreply.github.com> Date: Sun, 7 Jan 2024 21:56:00 -0800 Subject: [PATCH] Extract the first numerical output from free --giga --- quickemu | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/quickemu b/quickemu index 1ee87d3..b5f0125 100755 --- a/quickemu +++ b/quickemu @@ -320,9 +320,8 @@ function vm_boot() { local RAM_VM="2G" if [ -z "${ram}" ]; then local RAM_HOST="" - RAM_HOST=$(free --mega -h | grep Mem | cut -d':' -f2 | cut -d'G' -f1 | sed 's/ //g') - #Round up - https://github.com/wimpysworld/quickemu/issues/11 - RAM_HOST=$(printf '%.*f\n' 0 "${RAM_HOST}") + # Determine the number of gigabytes of RAM in the host by extracting the first numerical value from the output. + RAM_HOST=$(free --giga | tr ' ' '\n' | grep -m 1 [0-9]) if [ "${RAM_HOST}" -ge 128 ]; then RAM_VM="32G" elif [ "${RAM_HOST}" -ge 64 ]; then