I have a template file(template.txt):
Hello, $x
Hello, $y
I have a script file(script.sh):
#!/bin/bash
$x=linux
$y=unix
# I want to include template.txt as a here-doc
How to include template.txt as a here-doc of script.sh.
So that, when I run script.sh, the output should be:
Hello, linux
Hello, unix
Edit:
I think replace is a good command for my job:
$ cat template.txt | replace '$x' linux '$y' unix
A more sophisticated tool:
$ cheetah compile template.tmpl
$ x=linux y=unix python template.py --env
I use this function in one of my projects. It builds an actual here document from the template and then executes it in the current shell using
.: