^M Appearing after importing files from Windows

The ^M is due to Windows and Unix using a different characters for newlines. Windows' newline character shows up as ^M in UNIX text editors.

You can use the dos2unix command to remove the ^M characters. Simply run

dos2unix filename > newfilename

and what you specified as “newfilename” will contain your file, without the ^M characters.

You can then safely delete the old copy of the file with the ^M's in it.

Or, you can fix it with 'vi'. (This is useful in cases where you are logged onto a system without dos2unix installed.)

ESC :%s/CTRL-VCTRL-M//g
CTRL-V, CTRL-M are CONTROL+V and CONTROL+M
    :%s/^M//g,