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

Re: Detecting amount of memory?

bc will round the value down,  you need to change your calculation to round up  or using a different scale.

You would need to try it out, maybe something in the spirit of :

echo "scale 1; $memKB/1024.... |bc
if memGB -ge 5.5 ...


On Tue, Dec 21, 2010 at 2:18 PM, Patrick Lists <ks-list puzzled xs4all nl> wrote:

I trying to create a kickstart script on CentOS 5.5 that installs an RPM
depending on the amount of memory in the box. For example if the box has
>= 6GB memory then install RPM2 else install RPM1. With some Googling I
now have the following snippet:

memKB=$(free|grep Mem|awk '{print$2}')
memGB=$(echo "($memKB/1024)/1024"|bc)
if [ "$memGB" -ge 6 ]; then

yum install foobar$BIGMEM-1.0-1.rpm

The problem is that on a box with 6GB memory this snippet says it does
not have 6GB mem:

memKB = 6123716 KB
memGB = 5 GB

Anyone know what I am doing wrong?


Kickstart-list mailing list
Kickstart-list redhat com

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