[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting Msdos files to UNIX



perl -p -e 's/\r\n/\n/;' < input_filename > output_filename

Note that I've sometimes seen a ^Z at the end of dos text files.

todos/fromdos or unix2dos/dos2unix utilities are probably the best choice.

----- Original Message ----- 
From: "Stephen Colson" <scolson@westpole.com>
To: "Thorsten Glaser" <tg-2003m@netcologne.de>
Cc: <misc@openbsd.org>
Sent: Wednesday, April 30, 2003 9:07 AM
Subject: Re: Converting Msdos files to UNIX


> In the body of his email, he asked about ^M, so I gave him what he asked
for.
> Yes, *nix uses LF, Mac's use CR, and Dos uses CRLF. I gave him something
that
> would replace the ^M in question with a new line. If he wants to straight
out
> delete them, he can use:
> tr -d "^M" <input >output
>
> or as you suggested:
> tr -d '\r' <input >output
>
> In any event, it would not be specifically Mac->*nix, but rather CR -> LF
> which in this case (dos->*nix) will yield CRLF -> LFLF therby giving
multiple
> line breaks. The basis is still there--use tr.
>
> -s
>
>
> On Wednesday 30 April 2003 04:26 pm, Thorsten Glaser wrote:
> > begin  electrogrammati illius Stephen Colson
> >
> > >"[\012*]" is to replace ^M with the standard *nix newline char.
> >
> > Uhm, he wanted DOS->UNIX® and not Macintosh->UNIX®
> >
> > DOS uses CR+LF as newline, as per ISO 646
> > UNIX® uses LF as newline, as per ISO 9899
> > Macintoshen use CR as newline. Well, they did when I
> > last heard of them.
> >
> > //Thorsten