Storing blanks in an array in bash

Hi Guys,

I have a file which is as follows:

1
2
4
6
7

I am trying to store these values in an array in bash. I have the following script:

FILE=try.txt
ARRAY=(`awk '{print}' $FILE`)
echo ${ARRAY[0]}
 

This script is storing all the elements serially in the array.
So here is what I want:

ARRAY[0] = 1
ARRAY[1] = 2
ARRAY[2] =
ARRAY[3] = 4
ARRAY[4] =
ARRAY[5] = 6
ARRAY[6] = 7

Is there a way to stuff the array with blanks?

Thanks.

Put everything in quotes. "" is a blank.

Try this:

while read n
do
  ARRAY[$n-1]="$n"
done < file

Thanks, that worked.