Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

page break in awk

Status
Not open for further replies.

kwasserman

Technical User
Oct 21, 2004
7
0
0
US
I need to insert a page break (“\f”) in front of the first header line of a report, like this:

“\f”LP240 Date 06/21/10

I’m using the following awk code:

awk '{sub("LP240","\fLP240");print}' inputfile > outputfile

This works and inserts the page break, but I only want to do this for the first header line. If there is more than one page in the report then there will already be a page break for the next page header, and the awk code inserts a second page break, which will cause an extra blank page to print in the middle of the report. I only want to insert the page break for the header on the first page, and not touch any other header lines for subsequent pages.
 

Try:
Code:
awk 'BEGIN{printf "\f"}{print}' inputfile > outputfile
[3eyes]


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Dang ... doesn't get any easier that that. Thanks!
 
and awk isn't even necessary

Code:
(printf "\f"; cat inputfile)>outputfile

HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top