Welcome to the Linux Foundation Forum!

How to get variable value from a file

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:


  1. my name is $name

Here is my BASH script


  1. name=Brennan
  2. filecontent=$(cat test.txt)
  3. 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?

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training