[RndTbl] Little script puzzle help.
sean at ertw.com
Mon Jul 30 19:34:23 CDT 2012
Probably not the answer you want to hear now, but dude, you really need to
look into puppet or cfengine. Since I know you're stuck with a bunch of
different OSes, the latter might be better.
also help you with the sed /r, they have an example that does what
you want using patterns instead of line numbers.
On Mon, Jul 30, 2012 at 6:02 PM, Sean Cody <sean at tinfoilhat.ca> wrote:
> I have a file in which I need to replace a chunk of lines in on a bunch of
> My initial reaction was to use patch but that won'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.
> Then I was doing to do sed but I can't get the 'r' command do work as I
> need it to.
> 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...
> sudo vi $someconfigfile
> r ~/replacement.txt
> So what I'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).
> The question here is... is this possible to do with sed and if so how (my
> brain wont' make the right connections right now, must need a break/food or
> 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...)?
> I could just run a series of search&replace lines corresponding to each
> section in the replacement text doc but that'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).
> Some rules... solution shouldn't be perl/python/whatever because that
> won't necessarily be found on the UNIX hosts I'm using or may use in the
> future. Solution shouldn't use GNU extensions of sed/awk due to those
> being incompatible with non-GNU systems (ie. sysv,bsd,hp etc.).
> Any hits, takers?
> P.S. I'm doing this as a bit of a personal change management to replay
> some changes in the distant future (I'm typically using diff/patch for this
> though this case is a bit a-typical).
> Roundtable mailing list
> Roundtable at muug.mb.ca
Sean Walberg <sean at ertw.com> http://ertw.com/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Roundtable