lundi 22 juin 2015

If Statement bash command

Hi having problem with this code:

highmem="58.0"
counter=1
while [ $counter = 1 ];
do
       #sleep 5
       mem=`ps -C ats -o pid=,%mem= | awk {'print $2'}`
       echo $mem
       echo $highmem
       if [ "$mem" -gt "$highmem" ];
       then
        echo test
fi

Getting ./memtest: line 9: [: 20.3: integer expression expected

Can you please help. Need to do this ASAP. Can't figure it out what I'm doing wrong. I assume I'm comparing integer to text?

Aucun commentaire:

Enregistrer un commentaire