Re: Detecting amount of memory?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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" <ks-list@xxxxxxxxxxxxxxxxx> 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


_______________________________________________
Kickstart-list mailing list
Kickstart-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/kickstart-list


[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux