I'm trying to test if the variable $test
is between -0.9
and 0.9
. The following code works with numbers, but if $test
is a lower case letter, it says it's a number between -0.9
and 0.9
.
Is there a better way of doing this, so that letters are not considered to be in the range?
test=a
if (( $( echo "$test >= -0.9" |bc -l) )) && (( $(echo "$test <= 0.9" |bc -l) )); then
echo "${test} is between -0.9 and 0.9"
else
echo "${test} is NOT between -0.9 and 0.9"
fi