Home » Questions » Computers [ Ask a new question ]

Bash - read line from file

Bash - read line from file

I have a one-line file with a value stored as a string in it:

Asked by: Guest | Views: 214
Total answers/comments: 1
Guest [Entry]

"You can do a ""useful use of cat"" ;)

VAR = $(cat $(dirname $0)/server_name)

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."