Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Removing Carriage returns from text files

by stefan k (Curate)
on Oct 18, 2001 at 17:44 UTC ( #119678=note: print w/replies, xml ) Need Help??

in reply to Removing Carriage returns from text files

what's wrong with
perl -pi.bak -e 's/\r//' file(s)
? This is what I always use when d/l'ing code from the Monastery, because dos2unix (and friends) get confused when there is more than one type of EOL in the file(s). Or won't that handy perl-one-liner work in windows?

Update: typo

Regards... Stefan
you begin bashing the string with a +42 regexp of confusion

Replies are listed 'Best First'.
Re: Re: Removing Carriage returns from text files
by helgi (Hermit) on Oct 18, 2001 at 18:26 UTC
    Since none of the replies you have received so far actually solves the problem except under certain restricted circumstances, here is a little utility, macorpc2unix that we use here about a million times a day:
    #!/usr/bin/perl -w -i while (<>) {s/\r\n*/\n/g; print;}
    It will convert PC or Mac text files to Unix format. I see that you could rewrite it with a -p swithc and dispense with the while but I will leave that as an exercise.

    Helgi Briem

      we use here about a million times a day:

      But I bet only on *nix boxes, cause it wont work under win32.


      You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://119678]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2016-10-25 09:40 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (315 votes). Check out past polls.