dos to unix CR/LF conversion?

Peter L. Peres plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org
Sat Nov 8 22:30:20 UTC 2003


#!/bin/bash /usr/local/bin/u2d 755
awk '/\r$/ {printf("%s\n",$0);next;} {printf("%s\r\n",$0);next;}'

#!/bin/bash /usr/local/bin/d2u 755
tr -d '\r\032'

Use as filters, as in:

<myfile d2u >myfile.changed

do *not* use the same file for input and output. The input file will be
deleted if you do this.

Peter

On Sat, 8 Nov 2003, Max Blanco wrote:

>
> Kevin/All,
>
> you were right.  My mac/ie5 converted linefeeds to ^m, instead of \r.
> I can't see straight anymore between '\n', '\r', "^M", "^L", C, perl, tr,
> unix, dos, mac, dog, cat.  Arrgh.
>
> If any of you desire to get my hack/fix of the dos2unix source code, email
> me offlist.  If any of you would like to post a "tr" shell script that I
> can put into my /usr/local/bin directory, I'd be more than willing to copy
> it.
>
> cheers,
> max.
>
>
> On Sat, 8 Nov 2003, Kevin Cozens wrote:
>
> > At 02:55 PM 11/08/2003 -0500, max wrote:
> > >Unfortunately, at first glance, it seems to delete ^m but doesn't seem to
> > >insert ^r?  That's what happened to my text file.  That's just a minor
> > >tweak to the source code, though.
> >
> > Conversion of a text file from DOS to *nix is just a matter of deleting ^m.
> > If your text file has lines that end in ^m only then it is not a DOS text
> > file but possibly one from a Mac or other OS. This is where the 'tr'
> > command can be useful. It would allow you to change all ^m to ^r.
> >
> >
> > Cheers!
> >
> > Kevin.  (http://www.interlog.com/~kcozens/)
> >
> > Owner of Elecraft K2 #2172        |"What are we going to do today, Borg?"
> > E-mail:kcozens at interlog dot com|"Same thing we always do, Pinkutus:
> > Packet:ve3syb at ve3yra.#con.on.ca.na|  Try to assimilate the world!"
> > #include <disclaimer/favourite>   |              -Pinkutus & the Borg
> >
> > --
> > The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
> > TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> > How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
> >
>
> --
> The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
>
>
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list