Linux Bash – load declared variable from textfile


My situation :

Textfile : test.txt


Variable test declared in the terminal


Now when I cat the file, output is :


My question how can I cat the file with the declared output from the variable?


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)

Answered By – guthondr

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published