I need to write a simple script to replace a block of text in a configuration file with the contents of another file.
Let\'s assume with have the following simplifie
How about this little snippet I created:
sed -n \
-e "1,/<\!-- BEGIN realm -->/ p" \
-e"/<\!-- END realm -->/,$ p" \
-e "/<\!-- BEGIN realm -->/ r realm.xml" \
server.xml
The first commands prints the lines up to the second command prints the line starting at
and the third commands append the text in the file 'realm.xml'. If only I could simplify the removing of the lines between
and
without removing the marker lines it would as simple as it gets. And it can be done
inplace
with sed!!!