Friday, September 10, 2010

Remove ^M (Ctrl-M) character from the end of file

Sometimes you see ^M character at the end of the file, when you copy the file from windows.
Use below command in vi editor to remove them


:%s/^V^M//g


In UNIX, you can escape a control character by preceeding it with a CONTROL-V.

So what use see when you type the above commad, will be

:%s/^M//g


References: http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/

No comments:

Post a Comment