I'm trying to write a sed script that replaces the text enclosed between two markers with the contents of another file.
Say I have the following file with the markers <!-- Start --> and <!-- End -->:
# index.html
...
<!-- Start -->
<p>Old content</p>
<!-- End -->
...
And I want to replace the enclosed text with the content of this file:
# snippet.html
<p>New content</p>
I tried this sed script:
$ cat snippet.html | sed -i -e '/<\!-- Start -->/,/<\!-- End -->/ { r /dev/stdin' -e';d};' index.html
It replaces both the content and the markers, but I need to keep the <!-- Start --> and <!-- End --> markers so I can replace the content again in the future.
What changes should I make to the sed script?
Thanks in advance!