I'd like to use if-elif-elif-else-fi to determine a based on the range of t:
a=1000            # t=2-9.5
a=2000            # t=10-14.5
a=4000            # t=15-16.5
a=6000            # t=17-20
My bash file looks like:
t=(2 3 3.5 4 4.5 5 5.5 6 6.5 7 7.5 8 8.5 9 9.5 10 10.5 11 11.5 12 12.5 13 13.5 14 14.5 15 15.5 16 16.5 17 17.5 18 19 20)
len=${#t[*]}
for i in `seq 0 $((len-1))`
do
    if [ $(echo "${t[i]} < 10" | bc -l) -eq 1 ];then
       a=1000
    elif [[ "${t[i]}" -ge '10' && "${t[i]}" -lt '15' ]];then
       a=2000
    elif [[ "${t[i]}" -ge '15' && "${t[i]}" -lt '17' ]];then
       a=4000
    else
       a=6000
    fi
done
And I receive error "syntax error: invalid arithmetic operator (error token is ".5")".
It seems that I don't correctly compare the floating number with integer number. Can anyone help me to solve this problem? Thanks!
 
     
    