sed: Replacing a range of text with contents of a file
<p>There are many examples here and elsewhere on the interwebs for using sed's 'r' to replace a pattern, but it does not seem to work on a range, but maybe I'm just not holding it right.</p>

<p>The following works as expected, deleting BEGIN PATTERN and replacing it with the contents of /tmp/somefile.</p>

<pre><code>sed -n "/BEGIN PATTERN/{ r /tmp/somefile d }" TARGET_FILE
</code></pre>

<p>This, however, only replaces END_PATTERN with the contents of /tmp/somefile.</p>

<pre><code> sed -n "/BEGIN PATTERN/,/END PATTERN/ { r /tmp/somefile d }" TARGET_FILE
</code></pre>

<p>I suppose I could try perl or awk to do this as well, but it seems like sed should be able to do this.</p>