Compare float in bash
If you have a regular if and one of the integers has a float value like 1.200
you will get an error message.
The best way to do is using the bc command.
$ echo “7.1 > 7.1” | bc
$ echo “3.2 > 3.4” | bc
$ echo “7.2 < 7.4” | bc
Based upon it, we will modify our script, the if condition will be like this
if [ $(echo “$max < $val”|bc) -eq 1 ]
if [ $val -gt $max ]
So I do
if [ $(echo “$result < $maxconwarn”|bc) -eq 1 ]; then
It was kind of hard to find that info in the web and lots of people out there
saying to remove the data before the “.” but that was not the real solution.