What is `^M` and how do I get rid of it? - Unix Linux Stack Exchange The ^M is a carriage-return character If you see this, you're probably looking at a file that originated in the DOS Windows world, where an end-of-line is marked by a carriage return newline pair, whereas in the Unix world, end-of-line is marked by a single newline
What is the ^M character called? - Unix Linux Stack Exchange If you're using vim you can enter insert mode and type CTRL-v CTRL-m That ^M is the keyboard equivalent to \r Inserting 0x0D in a hex editor will do the task How do I remove it? You can remove it using the command perl -p -i -e "s \r g" filename As the OP suggested in the comments of this answer here, you can even try a ` dos2unix filename