I have a one-line file with a value stored as a string in it:
The file name is
server_name. What's the shortest, most elegant way to rad this value into a variable with bash script?
You can do a "useful use of cat" ;)
This will put the content of "server_name" file, located in the same directory as your script, into $VAR. Works regardless of where you run the script.
You can use the
Note that the variable is assigned without a dollar sign (
So you would want something like this:
I recommend that you use the full path of the file that you want to read rather than assuming that the two scripts will be in the same directory.
I won't swear that this is the most elegant solution.