Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

character ^M 1

Status
Not open for further replies.

Yarka

Technical User
Jan 14, 2007
192
ES
Hi,
I've a very long file which each line has character ^M in end of line. I edit the file with vi. I need to clear those characters. How can I erase it?

Thanks
 
To remove Microsoft's CRLF using perl do. This not only removes those annoying carriage returns, it also makes a backup of the original.
Code:
perl -i.bak -npe 's/\r\n/\n/g' [i]<filename>[/i]

M. Brooks
 
Thanks. You're a genius.
 
How difficult is it to learn perl if one knows shell ?
I found it very easy, particularly with the help of the "Llama book" (the O'Reilly "Learning Perl" book).

I hope that helps.

Mike
 
Try the commands [tt]unix2dos[/tt] and [tt]dos2unix[/tt]. They exist to do this kind of conversion. See the man pages for both.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top