Tuesday, 5 July 2011

How to remove "^M" (CTRL-M) characters

I used to see "^M" (CTRL-M) characters, when  i receive files via email or any other messengers, i could see this, 
you can use the these 2 methods to eliminate the "^M" (CTRL-M)

1.
$ vi <filename>
      [press Esc] then Enter  :%s/[ctrl-v][ctrl m]//g


2.
perl -pi -e 's/\r\n/\n/;' <filename>

eg: perl -pi -e 's/\r\n/\n/;' ApplicationResources.properties 



No comments:

Post a Comment