following command returns available memory in kilobytes
cat /proc/meminfo | grep MemFree | awk '{ print $2 }'
can some one suggest single command to get the available memory in gb?
Advertisement
Answer
Just a slight modification to your own magical incantation:
awk '/MemFree/ { printf "%.3f n", $2/1024/1024 }' /proc/meminfo
P.S.: Dear OP, if you find yourself invoking grep & awk in one line you’re most likely doing it wrong ;} … Same with invoking cat on a single file; that’s hardly ever warranted.