Saturday, November 26, 2011

sed insert lines after a specific line

Ha, that wasn't the google search that I typed in, but better.

The approaches to this problem involve either insert or append:

http://www.thegeekstuff.com/2009/11/unix-sed-tutorial-append-insert-replace-and-count-file-lines/

or my personal favorites, "next" and "print". In the following example, the found line is deleted, and only specific lines after that are printed (I don't need to delete the found line):

http://prefetch.net/blog/index.php/2007/12/03/printing-a-set-of-lines-after-a-pattern-match/

A really impenetrable suggestion for the same thing: What is capital N?

http://codesnippets.joyent.com/posts/show/2043

So anyhow, what I am going to whip up will be to find the matching line, print the next couple of lines, then do some appends to write out the new code lines.