

If you need an online course, I highly recommend Linux Mastery: Master the Linux Command Line in 11.5 Hours on Udemy. So the answer is no, you cannot eliminate the CR\LF (unless you write all your text in one line) but you can still remove those CTRL-M characters by using one of the two mentioned ways:īy the way, if you are new to Linux then I also suggest you go through a comprehensive Linux course to learn some basics commands and fundamentals like Linux file system, permissions, and other basic things. The control M characters appear in a file when you transfer them from Windows to UNIX (see How Linux works). Windows/DOS uses 2 characters: Carriage Return/Line Feed (CR/LF). Unix uses a single Line Feed (LF) character as the line break. Alternatively, you can use the VI command to open the file and replace ^M characters with nothing.

You can also use sed command (stream editor) to remove CTRL-M characters without opening the file, very useful if you are removing CTRL-M characters from a large file. There are several UNIX commands like dos2unix which can be used to convert Windows or DOS generated files to UNIX one. Is there any way that these ^M characters do not appear in the first place? Well, my search continues but I will share the solution which worked for me for removing control M characters i.e. I searched about this but the solutions were to remove these ^M characters when files are transferred using utilities. I wanted to transfer some files from Windows to Unix using FileZilla, but the problem arises when these files are transferred (Ascii or Binary mode both) and opened using VI we get ^M characters, also known as CTRL-M characters.
