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!

Replacing special char PageBreak with NewLine 2

Status
Not open for further replies.

Calator

Programmer
Feb 12, 2001
262
AU
A Unix application creates its reports so that each line ends in ^M, and the next row after a page break ^L appears on the same line when viewed with emacs, eg:

page 1 row 1 ^M
...
last report line on page 1 ^M^L----first report line on page 2 ^M
page 2 line 2 ^M

I need to replace in a ksh script, the ^L with a newline character so that I force the following report line in a row of its own. I don't need the page break.

I tried: sed 's/^L/\n/g' $in_file > $temp_file
but that results in:
last report line on page 1 ^Mn----first report line on page 2 ^M

Any ideas? using sed? any other representation for the newline character, eg ^?


 
You may try this:
awk '{gsub(/\f/,"\n");print}' $in_file > $temp_file

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks a lot, this worked ok.

New similar question: I catenate 2 text files, followed by emailing them. The emailed resulting file, when opened in Notepad, shows the first line in file no2 appended to the last line in file no1.
I guess I need to insert a linefeed after ^M in the last record of file no1, how can I do that?

Do you have a solution using "sed" as I am more familiar with sed syntax, no experience with "awk"? Thanks!
 
(cat file1; echo ''; cat file2) > file2mail

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Thanks Vlad,
this also worked!

Any ideas using sed? How do you represent the newline character for sed? Eg cr is ^M, but what is newline?

 
Hi:

You might want to check out this faq:

faq80-1911

located in the General Unix Forum. There's a stub sed script you might find interesting:

sed 's/'"$(printf '\015')"'$// .......

Where the octal value of CR is \015

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top