Get rid of ^M in file
In fact, a ‘^M’ in text file is a carriage return (CR), often introduced by DOS text file format. It’s possible to do a simple substitution to get rid of it.
Easiest way is to use a dedicated tool called `dos2unix’, and yes, there is a corresponding tool called `unix2dos’.
Or, we can use Vim/Emacs to convert it.
(first open file with Vim) :set ff=unix :set ff=dos
Or use Vim command line switches.
$ vim +"set ff=unix" +wq $DOS_FILE
In Emacs, just do a substitution. Use C-q C-m to input ^M.