I spent a lot of time to figure out what is the reason I get error in the following simple code. I appreciate if anyone can solve it.
i=0
while read line
do
if [[ -z "$line" ]]; then
echo "End of numbers"
break
else
{
echo "$line is not empty"
array[$i] = $line
echo array[$i]
((i += 1))
}
fi
done
output:
sss
sss is not empty
command.sh: line 10: array[0]: command not found
array[0]
ss2
ss2 is not empty
command.sh: line 10: array[1]: command not found
array[1]