0

I have two arrays. One containing city names and the other with numbers with decimals. I wanted to make a statement where I pick the lowest number, and based on the position of that number I choose the city. what I have so far looks like this:

min=1000
for j in {1..9};
do
        for g in "${array2[$j]}";
        do

                if [ $g -lt $min ]; then
                        min = $g
                        city2="${array[$j]}"
                fi
done;
done;
echo $city2

I get an error saying an integer is expected. How could I fix this? I know it has something to do with the fact that my numbers have decimals.

Daniel
  • 373
  • 1
  • 10
  • Generally, that means that the value you pulled out of your array *isn't* an integer. You aren't showing us a definition for `array2`, so there's no [mre] here; the code isn't complete enough for someone else to run and see the problem. – Charles Duffy Mar 12 '20 at 22:13
  • Also, `min = $g` isn't an assignment -- it runs a command `min` with an argument `=` and other argument(s), if any, depending on `$g`. If you want to change `$min`, make it `min=$g` with no spaces. – Charles Duffy Mar 12 '20 at 22:13

0 Answers0