Control M ( ^M) characters are introduced when you use lines of text from a windows computer to Linux or Unix machine. Most common reasons are when you directly copy a file from a windows system or submit form data copied and pasted from a windows machine.
Detecting ^M characters
^M is non printable character and often becomes difficult to find, in order to see if your file contains any non printable character use the cat command with -v option
$cat -v filename
Methods to remove ^M
In all these method , real secret is not to type ^M using keyboard but rather typing in control key sequence to get the ^M control character. Continue reading “How to Remove ^M in Linux & Unix”