in reply to converting windoze end-of-line chars to unix

Here is a one liner that "fixes" text file newlines to match your current platform (so will make a DOSish file UNIXy under UNIX but make a UNIXy file DOSish under DOS).

perl -pe "s/\r*$//" infile >outfile
Note that it doesn't handle the very silly CTRL-Z-is-EOF of DOS, which I haven't had problems with recently.

\m was a good guess but \Cm or \r is what you wanted. No need to use "cat". "-p" is like "-n" except you don't need to have the "print".

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re: converting windoze end-of-line chars to unix
by spaz (Pilgrim) on Dec 29, 2000 at 06:27 UTC
    If I may improve (slightly)
    perl -i.orig -pe "s/\r*$//" file
    The -i.orig makes a temp file (file.orig) incase the conversion doesn't work right.