Unix Programming - sed to insert lines in a file.

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2004 > sed to insert lines in a file.





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author sed to insert lines in a file.
Ken Weise

2004-01-23, 4:56 pm

I need to insert multiple lines into a postscript file. I think I can
use sed to do this. I actually have it working, sort of...

I need to insert 9 lines of postscript code into a postscript file
after each line starting with %%Page:

I was thinking I can use the append command with sed, but that only
works for one occurence. I need to be able to insert the lines after
each occurrence of %%Page:, any suggestions? Thanks!!
Rouben Rostamian

2004-01-23, 4:56 pm

In article <epdnrv4doj5ci34km1ft49is2tu92a7fot@4ax.com>,
Ken Weise <kweise@econocaribe.com> wrote:
quote:

>I need to insert 9 lines of postscript code into a postscript file
>after each line starting with %%Page:



Make a file, say my.sed, that contains:

s/^%%Page:.*/&\
added line 1\
added line 2\
added line 3\
added line 4/

Add more lines as needed. Then:

sed -f my.sed < infile.ps > outfile.ps


--
Rouben Rostamian
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com