Kind of new to bash scripting and is having trouble with the below code. I am trying to compare the array number with the number you have input from the "read ans" the problem is mostly comparing decimal numbers
BGpercent=(0 99 99.3 99.6 99.8 100)
BGpoint=(0 1 2 3 4 5)
read ans
for (( c=${#BGpercent[@]}; c>=0; c-- ))
do
echo "${BGpercent[$c]}"
if [ "${BGpercent[$c]}" <= "$ans" ];
then
result=${BGpoint[$c]}
break
fi
done
echo $result | bc -lstrong text
Error - ./testscript.sh: =: No such file or directory
=:is strange.