My situation :
Textfile : test.txt
$test
Variable test declared in the terminal
test=hello
Now when I cat the file, output is :
$test
My question how can I cat the file with the declared output from the variable?
CodePudding user response:
cat itself does not evaluate any variables. To do it, the command line must be evaluated by bash twice. This is done by the eval command. Thus the result should be
eval echo $(cat test.tex)
CodePudding user response:
Add export in the file then execute it
example
export test="Hi I'm Ender"
Then try to
source ./blabla.txt
Note : You need echo not cat
Also your can use
test="Yes"
Or maybe your asking how to execute variable in script?