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?
[me@home]$ sed -e '/\$xxx/r content.txt' -e '/\$xxx/d' template.txt
.,:;-+=_'"`*^?!
.,:;-+=_'"`*^?!
&$%#@|/\()[]{}<>
&$%#@|/\()[]{}<>
The first command searches for $xxx
then prints out the contents of content.txt
. The second one deletes $xxx
.
You can also use a multi-line command, which would be more readable when used in scripts.
sed -e '/\$xxx/{
r content.txt
d
}' template.txt