Click to See Complete Forum and Search --> : BASH - assign file contents to variable


nanode
01-30-2002, 03:32 PM
I'm pretty decent with basic bash scripting, but I cannot figure out howto assign the contents of a text file to a variable.

Suppose I have a file foo.log and I want to assign it to x

Is there a way to pipe so that:

x=(contents of foo.log)

Thanks

Gnu/Vince
01-30-2002, 03:56 PM
x = `cat foo.bar`

??

nanode
01-30-2002, 04:10 PM
yup - I needed to use the ` around the operation :(