Results 1 to 4 of 4
In a script using bash, I would like to assign the contents of a file to a variable. How can I do this in a simple manner?...
- 08-30-2004 #1Just Joined!
- Join Date
- Aug 2004
- Location
- New Mexico
- Posts
- 2
Assigning file contents to variable
In a script using bash, I would like to assign the contents of a file to a variable. How can I do this in a simple manner?
- 08-30-2004 #2Linux User
- Join Date
- Jul 2004
- Location
- Poland
- Posts
- 368
For example by:
note, there are no spaces around assignment and I'm using backstics (below tilde char) to execute cat file.txt and return its output.Code:varname=`cat file.txt`
"I don't know what I'm running from
And I don't know where I'm running to
There's something deep and strange inside of me I see"
- 08-31-2004 #3Just Joined!
- Join Date
- Aug 2004
- Location
- New Mexico
- Posts
- 2
Thanks, kyku. I had seen this solution before but just assumed that the backsticks were single quotes italicized.
- 09-01-2004 #4Linux User
- Join Date
- Jul 2004
- Location
- Poland
- Posts
- 368
As an end matter, there's a clearer solution: $(progname arg1 arg2 ... argn)
"I don't know what I'm running from
And I don't know where I'm running to
There's something deep and strange inside of me I see"


Reply With Quote
