Tuesday, October 16, 2007

How to delete ^M at the end of line in UNIX

Saw this in another post. It is useful and easy to do.

^M is DOS line break character which shows up in UNIX files when uploaded from a windows file system in ascii format.

To remove this, open your file in vi editor and type

:%s/(ctrl-v)(ctrl-m)//g

and press Enter key.

Important!! - press (Ctrl-v) (Ctrl-m) combination to enter ^M character, dont use “^” and M.

2 comments:

Anonymous said...

In Solaris, there is an utility called "dos2unix".

dos2unix originalfile convertedfile

Anonymous said...

You write very well.