Today I was trying to compare two values and surprised what I saw. I didn't find any good suggestion anywhere. Could any one please help?
if [ 10.94 -gt 10 ]
then
echo True
else
echo False
fi
I am surprised here the result is False.
Then I tried the following.
if [[ 10.94 > 10 ]]
Result came as True. I was fine with it.
Again my script gave a flaw at a particular condition like below
if [[ 5.15 > 10 ]]
echo True
fi
Here result came as True.
How come? Is there any better idea, which will compare the decimal values in a proper way?
>is a string comparison,-gtis arithmetic and only accepts integers.kshreturnsTrue