This question already has an answer here:
I'm trying to have two layers of indirection, though let me know if I'm a victim of the XY problem
Boiled Down Explanation of What I'd Like to Achieve
> test1=\$test2 > test2="string to print" > echo $test2 string to print > echo $test1 $test2
This all makes sense, but what I want is to perform a command using
$test1 and print out
string to print. My gut reaction was that this should work
> echo $(echo $test1) $test2
Bollocks. Does anyone else know if this is possible?
More Detailed Explanation of Why I Wish to Accomplish This
I want to create a text file template containing
$variables which can be re-used to generate many text files. My thinking is: set environment variables, process the template file and output to another file.
> #set vars > cat template.txt | magic_var_expansion_cmd > out1.txt > #set vars > cat template.txt | magic_var_expansion_cmd > out2.txt > #set vars > cat template.txt | magic_var_expansion_cmd > out3.txt
This could obviously be used in a script, and in more sophisticated ways but this is the MVP in my mind's eye.