What is M in Linux? 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.
How do I remove CTRL-M characters in Linux?
- The easiest way is probably to use the stream editor sed to remove the ^M characters. Type this command: % sed -e “s/^M//” filename > newfilename.
- You can also do it in vi: % vi filename. Inside vi [in ESC mode] type: :%s/^M//g.
- You can also do it inside Emacs.
How do you type an M character? To enter ^M, type CTRL-V, then CTRL-M. I mean, hold down the CTRL key then press V and M in succession. The sed command is really helpful in case of removing ^M characters from large and huge files because you don’t need to open the files into VI or any other editor.
What is M in text files? It is a carriage return. DOS/Windows editors tend to use a carriage return and a line feed, Unix editors like to use just the line feed. Some editors like geany and textpad can detect it and dont show you the ^M, and some will let you do a save as where the choices include unix style or crlf style.