Stripping Carriage Return / Line Feed from text file

John Esak john at valar.com
Tue Jul 29 21:09:40 PDT 2008


I have always used JP's teeny tiny script he wrote for The Guru magazine 100
years ago.  But, alas it is only for *nix. Here is is.  You put it in your
path (/usr/local/bin) and call it addcr, then link it to delcr with:

Ln addcr delcr 

Thatw way it workds in either direction based on the program you call.

Addcr unixfile windowsfile
Delcr windwsfile unixfile

Nifty, compact, protable to any *nix.


: Carriage-Return converter  - JP. Radley for The Guru
       # addcr : adds CRs
       # delcr : removes CRs
       [ $# -ne 2 ] &&
       echo Usage: $0 infile outfile && exit
       case $0 in
               *addcr) sed s+$+^M+ <$1 >$2;;
               *delcr) sed s-^M--g <$1 >$2;;
       esac
~
~
~




> -----Original Message-----
> From: filepro-list-bounces+john=valar.com at lists.celestial.com
> [mailto:filepro-list-bounces+john=valar.com at lists.celestial.com] On Behalf
> Of Bill Campbell
> Sent: Tuesday, July 29, 2008 6:47 PM
> To: filepro-list at lists.celestial.com
> Subject: Re: Stripping Carriage Return / Line Feed from text file
> 
> On Tue, Jul 29, 2008, Kenneth Brody wrote:
> >Quoting Scott Walker (Tue, 29 Jul 2008 17:27:13 -0400):
> >
> >> I want to use a text file as an alien file.
> >>
> >> It's fixed length fields but has a carriage return/line feed between
> >> each record.
> >>
> >> Can someone remind me of the easiest way to strip the 0d0a from these
> >> records.
> >
> >Why not just add a (2,*) field at the end of your map, and just ignore
> >that field?
> 
> I like the SCO program to do this, dtox -- aptly named to detox
> things from Microsoft (yeah this was originally a CP/M thing :-).
> 
> Bill
> --
> INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
> URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
> Voice:          (206) 236-1676  Mercer Island, WA 98040-0820
> Fax:            (206) 232-9186
> 
> The best we can hope for concerning the people at large is that they be
> properly armed.  -- Alexander Hamilton, The Federalist Papers at 184-188
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> http://mailman.celestial.com/mailman/listinfo/filepro-list



More information about the Filepro-list mailing list