Re: Detecting amount of memory?

Patrick Lists <[email protected]>
Newsgroups gmane.linux.redhat.kickstart.general
Message-ID <[email protected]>
On 12/21/2010 02:05 PM, Callahan, Tom wrote:
> The trick is, 6123716 KB isn't actually 6GB, it's slightly less. That's why
> you are getting the results you are getting.
> 
> http://www.google.com/search?q=6123716KB+in+GB
> 
> 
> On 12/21/10 7:18 AM, "Patrick Lists" <[email protected]> wrote:
> 
>> 6123716

Yup see that now. Still I wonder why free says MemTotal is less than 6GB
when the box has 6GB. That's the interesting part. I seem to be missing
something. Where did those last few bytes go? Or could this be a case of
GB versus GiB.

Strangely this awk line does work but I have no awk foo so this is like
dark arts to me (line 2,3,4 should all be on one line):

mem=$(free|grep Mem|awk '{print$2}')
echo "$mem" | awk '{ n = $0; sub(/[0-9]+(.[0-9]+)?/, ""); split(n, a,
$0); n=a[1]; if ($0 == "G" || $0 == "") { n *= 1024 }; if (/^kB?/) { n
/= 1024 }; printf "%d\n", n }'
# Intentionally rounded to an integer

Regards,
Patrick
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.