ksh: How to store each output line into a different variable?

Example output:

/tmp/generatelines.sh
line1
line2
line3
line4

I want each output line assigned to its own variable, ie:

"line1" --> $a
"line2" --> $b
"line3" --> $c
"line4" --> $d

Is this possible without writing to a temporary file?

Thanks

ifs='
'
read $a $b $c $d <file

very inefficient if you start to change the number of lines, or variables required. Have you considered an array,

Thanks for your fast response.

Unfortunately read only reads the first line, even if I set IFS like you did.

This is what happens:

nptcmc01,sys,root # (
> IFS='
> '
> read a b c d < file
> echo $a
> echo $b
> echo $c
> echo $d
> )
line1

nptcmc01,sys,root #

Please advise me how I could do this with an array. I have been trying to work this out for days!

ifs="$IFS"
IFS='
'
set -A lines $(</tmp/generatelines.sh)
IFS="$ifs"

Then you have the lines in ${lines[0]} ... ${lines[n]}

And of course, if you have a line like:

a\nb

... and you want to display the element correctly,
you should use print -r.

Hi radoulov

Your code works perfectly. You have taught me something new and I am extremely grateful.

Regards