I am trying to compare two numbers stored in variables in a shell script. The objective is to find if the incoming value is inside the specified ranges: 500-600
or 700-800
.
My current code looks like:
inc=0
srange[0]=500
erange[0]=600
srange[1]=700
erange[1]=800
for i in "${startrange[@]}"; do
if [[ " ${startrange[$inc]} " -lt " $actual " ]]; then
echo " in range "
fi
inc = $((inc+1))
done
The code works with integer values such as 530
or 540
but fails with decimal values like 530.2
or 540.3
, resulting in a syntax error on this line of the code:
if (( " ${startrange[$inc]} " -lt " $actual " )); then
How can I fix this to handle the decimal values?