I'm getting an error saying
"line 6: [: : integer expression expected"
and I can't figure out what to do to fix it. I'm trying to write a script to print out 200 equations, the equations should be of form "i * j = k" where i is an integer between 1 and 10, j is between 1 and 20, k is the product of i and j.
#!/bin/bash
for i in {1..200..1}
do
if [ "$i" -gt 0 ] && [ "$i" -lt 11 ] && [ "$j" -gt 0 ] && [ "$j" -lt 21 ]
then
i = 1
j = 1
k = $(($i * $j))
echo $i * $j = $k
((i++))
((j++))
fi
done
$jis undefined on the first pass through the loop?echoor it tries to expand*, and you'll end up with1 * 1 = 1for every loop because you setiandjto 1 before the calculation. shellcheck.net would have uncovered at least the spaces.