assign value to array variable

Hi,
I have a piece of code as follows:

i=0
while read LINE
do
        var = "$LINE"
i=$((i+1))
echo "${var}"
done < file

I want to assign value to the array var[i].
However, when i execute the script i get a error.

Please can you help me know what i am missing.
I ultimately want to store input values in a array got from the user

Thanks.

I think you want var[$i]="$LINE" Also note the lack of spaces around the equal sign.

But without knowing your system and shell it's difficult to be sure. What are they?

1 Like

I am using Red hat linux with a bash shell.
By the way. thanks i was missing that thing and you pointed it out right.
thanks again.