Extract the first numerical output from free --giga

This commit is contained in:
Liam 2024-01-07 21:56:00 -08:00 committed by Martin Wimpress
parent b3802a356e
commit 98e44bbaa8
1 changed files with 2 additions and 3 deletions

View File

@ -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