Welcome to the Linux Foundation Forum!

How to get variable value from a file

Brennan
Brennan Posts: 1
edited July 2018 in New to Linux

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?

Categories

Upcoming Training