Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2018-02-21 01:52 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (274 votes). Check out past polls.