Friday, November 7, 2008

How to remove ^M, the DOS line break character.

To remove the extra ^M character that shows up in files that are transferred to the Unix system from the Windows platform (having ASCII format for the files) :

1) Press Esc and type ":"
2) %s/(ctrl-v)(ctrl-m)//g

The basic search and replace command in unix is %s. The pattern between the first and the second slash (which is ^M) is replaced by the pattern between the second and third slash (which is empty space here). The "g" at the end of the command implies that the global replacement is being done in the file.

No comments: