Something like:
cat template.txt | ruby -e 'puts STDIN.read.sub("%placeholder%", IO.read("content.txt"))' > output.txt
Or:
ed template.txt <<EOF
/%placeholder%/d
.r content.txt
w output.txt
EOF
Any alternatives?
Something like:
cat template.txt | ruby -e 'puts STDIN.read.sub("%placeholder%", IO.read("content.txt"))' > output.txt
Or:
ed template.txt <<EOF
/%placeholder%/d
.r content.txt
w output.txt
EOF
Any alternatives?
The first command searches for
$xxx
then prints out the contents ofcontent.txt
. The second one deletes$xxx
.You can also use a multi-line command, which would be more readable when used in scripts.