This file was probably opened and saved in a windows text editor.
The end of line character in UNIX based systems are different from that of windows.
Text files created on DOS/Windows machines have different line endings
than files created on Unix/Linux. DOS uses carriage return and line
feed ("\r\n") as a line ending, which Unix uses just line feed ("\n").
You need to be careful about transferring files between Windows
machines and Unix machines to make sure the line endings are
cat the file, the EOL character will not be displayed, however, when you read the file using
vi, it will be.
The easiest way to remove
^M from the file, is probably to use the stream editor
sed to remove the
^M characters. Type this command:
% sed -e "s/^M//" filename > newfilename
CTRL-M. That is, hold down the CTRL key then press V and M in succession.