reading line by line from a text file

Hi,
I have a text file something like this:

10.10.10.1,
ldap,
cn=users,dc=example,dc=com
.....
...
and many more lines
...
...

now i want to read each individual line from the file and assign it to a variable

example:
the script should read

10.10.10.1

and assign it to a variable say $x
like $x=10.10.10.1
and then read the next line

cn=users,dc=example,dc=com

and assign that to another variable like
$y=n=users,dc=example,dc=com
and so on.

Please any idea on how can i achieve this, esp reading each line from a file and storing it in a variable.

thanks.

Read the list of related threads at the bottom of this thread - similar questions have been asked/answered many times.

Are you sure you want separate variables for each line?
Could you please tell what are you trying to achieve?

If you do need, you can try something like,

i=1
while read LINE
do
 eval $(eval echo var$i="$LINE")
 i=`expr $i + 1`
done < file
 
 
echo $var1
echo $var2
echo $var3