Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

How to remove ^M from a file

by Tii (Monk)
on Aug 01, 2000 at 20:41 UTC ( #25499=perlquestion: print w/replies, xml ) Need Help??

Tii has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, Monks...

Please forgive me for asking a redundant question, but before posting this, I searched for the answer to no avail:

How can I replace the ^M found in a file (usually after it has been ftp'ed in binary format instead of ascii)?

Even better, is there a way to delete the lines that contain only ^M?

Thanks,
Tii

PS: I remember that this question was asked before and the answer was something that could be done on the command line.

Replies are listed 'Best First'.
Re: How to remove ^M from a file
by Russ (Deacon) on Aug 01, 2000 at 20:46 UTC
RE: How to remove ^M from a file
by DrManhattan (Chaplain) on Aug 01, 2000 at 21:53 UTC
    perl -pi -e 's/\r//g' filename

    -Matt

RE: How to remove ^M from a file (dos2unix)
by ybiC (Prior) on Aug 01, 2000 at 22:17 UTC
    A not-at-all perlish method would be some variation of the *nix command dos2unix.

    A slightly-more-perlish approach might be the Power Ptools equivelent nlcvt.
        cheers,
        ybiC

Re: How to remove ^M from a file
by Tii (Monk) on Aug 01, 2000 at 22:40 UTC
    Thanks to everyone for the help!

    Tii

Re: How to remove ^M from a file
by Buckaroo Buddha (Scribe) on Aug 02, 2000 at 19:26 UTC

    sorry for the -- but it's my opinion that if you know that
    a question has been asked before then it is more polite to
    either search for that question yourself or ask for help finding
    the link to that question in the chatterbox

    maybe it was wrong of me to do it, but that's the reasoning for it
    if you disagree you can -- me back :) Update:

    on the other hand a 'thank you' post is perfectly acceptable!! (++ ;)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://25499]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2019-09-23 07:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (277 votes). Check out past polls.

    Notices?