Remove ^M characters using vi
To remove all "^M" characters from a file, open it in vi and use this command:
The "^M" in the above line has to be typed in by pressing CTRL+v and then CTRL+M.
:%s/^M//g
The "^M" in the above line has to be typed in by pressing CTRL+v and then CTRL+M.