Bourne Shell : How to insert some lines of text to a given line number of a file

Posted by orgazoid on Stack Overflow See other posts from Stack Overflow or by orgazoid
Published on 2010-04-22T16:56:50Z Indexed on 2010/04/22 17:03 UTC
Read the original article Hit count: 155

Filed under:
|

I'm writing a Bourne Shell script to automatically edit a source file.

I get the line number I need like this:

line=`sed -n '/#error/=' test.h`
line=$[$line - 2]

Now I want to insert a few lines of text after this line number, how can I do this?

© Stack Overflow or respective owner

Related posts about bourne-shell

Related posts about sed