the problem is in this line
elif [ "$(echo $a '>' $v06 | bc -l)" -eq 1 && "$(echo $a '<' $v08 | bc -l)" -eq 1 ];then
How can I test if the number is in range ?
I know that there might be other solution for this but I want to solve in this way with bc…
a=0.1
v06=0.6
v08=0.8
if [ "$(echo $a '<' $v06 | bc -l)" -eq 1 ];then
echo " <0.6"
elif [ "$(echo $a '>' $v06 | bc -l)" -eq 1 && "$(echo $a '<' $v08 | bc -l)" -eq 1 ];then
echo " <0.6 >0.8"
else
echo ">1.5"
fi
If you really want to use bc:
I recommend to use braces around a variable (so you are sure 06 and 08 won’t be append to
$v), use double brackets in your tests if you are using operators like&&.