A message for Linux.com registered users: We are in the process of making changes to the Linux forums. Starting Monday, 8/13/18 at 6:00 PM PT, you will be unable to access the forums. They will re-launch as soon as possible on Wednesday, 8/15/18 with new features and improved functionality. Thank you for your patience and stay tuned for the new improved forums.

July 30, 2018

How to get variable value from a file

Forums: 

HI All

This is my first time posting question here. Hope I post in the correct forum.

I have a question about variable.

I have a file (test.txt) with content like:

my  name is $name

Here is my BASH script

name=Brennan

filecontent=$(cat test.txt)

echo $filecontent

I would like to display my result as  my name is Brennan. However, my script returns my name is $name

Could you please guide how could I get the expected result?

Click Here!