reading a file into a varable...

Hi all,

I have had a hunt round the net (and the forum (more importantly)) but carn't just see anything that helps. Does anyone care to put me out of my missery and tell me how to read a file into a variable?

thanks,

B14... aka... Marky Mark...

try this....

var="`cat file`"

But what do you want to achive through this??

regards
Apoorva kumar

well its pretty simple really to be honest. I have a couple of SQL scripts that output some numbers to file, I just want to read them into my script so that I can compare them.

Thanks I will try this out,

Mark.

You want to read the entire file into a single variable? At one shot? Dunno if you can do that and keep it readable by anything else... To read the file a line at a time, you can see this thread.

Well the above does work (under Solaris 5.8) but you see, the files that I am reading are only contain 1 set of numbers (eg could be 1, it could be 14,0954) so I just wanted to read them into a variable and use the numbers in another script.

Thanks for the replies though,

Mark.