Probably not the answer you want to hear now, but dude, you really need to look into puppet or cfengine. Since I know you&#39;re stuck with a bunch of different OSes, the latter might be better.<div><br></div><div><a href="http://stackoverflow.com/questions/6744639/sed-awk-remove-lines-from-pattern-to-pattern">http://stackoverflow.com/questions/6744639/sed-awk-remove-lines-from-pattern-to-pattern</a> might also help you with the sed /r, they have an example that does what you want using patterns instead of line numbers.<br>
<div><br></div><div>Sean<br><br><div class="gmail_quote">On Mon, Jul 30, 2012 at 6:02 PM, Sean Cody <span dir="ltr">&lt;<a href="mailto:sean@tinfoilhat.ca" target="_blank">sean@tinfoilhat.ca</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have a file in which I need to replace a chunk of lines in on a bunch of hosts.<br>
<br>
My initial reaction was to use patch but that won&#39;t suffice because the chunk of lines will be different on each host (possibly) so the source part of the patch may not aline to the diff.<br>
<br>
Then I was doing to do sed but I can&#39;t get the &#39;r&#39; command do work as I need it to.<br>
<br>
So I wrote down a series of vi commands to do what I need to do now I just need to convert that into a sed/ex script...<br>
<br>
sudo vi $someconfigfile<br>
23,56d<br>
23<br>
r ~/replacement.txt<br>
ZZ<br>
<br>
So what I&#39;m doing here is just dumping lines 23 through 56 in some file and inserting a replacement chunk of text (my not necessarily be 56-23 lines long).<br>
<br>
The question here is... is this possible to do with sed and if so how (my brain wont&#39; make the right connections right now, must need a break/food or something).<br>
<br>
Even better how would this be done with ex (as I can do a bunch of manual vi commands, how would one automate a repeatable vi session...)?<br>
<br>
I could just run a series of search&amp;replace lines corresponding to each section in the replacement text doc but that&#39;s violating the spirit of the problem (ie. replace a chunk of text at an arbitrary point in a file with a different chunk of text located in a different file).<br>

<br>
Some rules... solution shouldn&#39;t be perl/python/whatever because that won&#39;t necessarily be found on the UNIX hosts I&#39;m using or may use in the future.  Solution shouldn&#39;t use GNU extensions of sed/awk due to those being incompatible with non-GNU  systems (ie. sysv,bsd,hp etc.).<br>

<br>
Any hits, takers?<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Sean<br>
P.S. I&#39;m doing this as a bit of a personal change management to replay some changes in the distant future (I&#39;m typically using diff/patch for this though this case is a bit a-typical).<br>
<br>
<br>
_______________________________________________<br>
Roundtable mailing list<br>
<a href="mailto:Roundtable@muug.mb.ca">Roundtable@muug.mb.ca</a><br>
<a href="http://www.muug.mb.ca/mailman/listinfo/roundtable" target="_blank">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Sean Walberg &lt;<a href="mailto:sean@ertw.com" target="_blank">sean@ertw.com</a>&gt;    <a href="http://ertw.com/" target="_blank">http://ertw.com/</a><br>

</div></div>