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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

append text at every 94 line. 1

Status
Not open for further replies.

dbase77

Technical User
Apr 23, 2002
591
IE
Hi,

Is there a way to append text at every 94 line in a file? I have a big file. At every 94 line I have "^M". What I want to do is add "^L" before it. So it will look like "^L^M". Can anybody help with this, please? I tried to google but no luck so far.

Thank you in advance.

regards,
dbase77
 
A starting point:
awk 'NR%94==0{sub(/\r/,"\f\r")}1' /path/to/input > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi,

Thank you for replying. Dont quit understand the first part. The second part "sub" is for substitution for \r (carriage return) and \f\r (formfeed and carriage return). But when I run it I got error:

awk: syntax error near line 1
awk: illegal statement near line 1
awk: syntax error near line 1
awk: bailing out near line 1

I'm a newbie. Please go slow on me.
 
If you have it, try nawk (or gawk).

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi,

Thank you. Can you explain the following, please?

NR%94==0

and number 1 at the end.

Thank you.
 
hmmm strange. When I print the file, it prints extra page at every ^L^M. Do you know why?

regards,
dbase77
 
Yes, ^L is a FormFeed.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The reason I put ^L at every new page (line 94) was to print the file properly. If not, it won't print when it reaches to new page, instead it just add blank line from previous page to it owns page. So on the second page and so on, I got this huge empty page. If you understand what I mean. So, how do I get rid this extra page and print the file properly? Any ideas?

Thanks again.

regards,
dbase77
 
Or perhaps this ?
awk 'NR%94==0{printf $0"\f";next}1' /path/to/input > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
needcoffee,

Same effect I'm afraid. It still prints extra page.
 
What are your queue settings for this printer and what type of printer? Perhaps your settings need a tweak.

[morning] needcoffee
 
Hi,

I'm running running jet direct admin from HP and my printer is HP laserjet 4200N. I'm on solaris8.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top