Can you please suggest to me the syntax for doing floating point comparison in a Bash script? I would ideally like to use it as part of an if statement. Here is
Using the exit() function of awk makes it almost readable.
key1=12.3
result=12.5
# the ! awk is because the logic in boolean tests
# is the opposite of the one in shell exit code tests
if ! awk "{ exit ($result <= $key1) }" < /dev/null
then
# some code here
fi
Note that there is not need to reuse the [ operator as if already uses the exit value.