Text files do not come in a universal format. If you have ever opened a text file on Windows with Notepad and all the lines were running together – that file was probably created on a Unix or Linux system. This is caused by a different way that Unix systems mark each End-of-Line (EOL).
In the Unix and Linux world, text file lines end with a single invisible character known as the “NEW-LINE” or “LINE-FEED” (LF). Unix and Linux programmers will be familiar with the newline character by the common escape sequence “\n” used in C, C++, and many other popular programming or scripting languages.
In the Windows and DOS world, text file lines end with two invisible characters often abbreviated as “CRLF”. The first character is the “CARRIAGE-RETURN” followed immediately by a “LINE-FEED”. Windows and DOS programmers will recognize this common escape sequence pattern as “\r\n”.
Now that we have a brief overview of the differences, let’s look at some tools that help you convert a file from one format to the other. For Windows users, the popular Notepad++ editor has an “EOL Conversion” tool under the Edit menu. For Red Hat Enterprise Linux (RHEL) and CentOS users, the unix2dos and dos2unix command-line utilities provide the same functionality – they can be installed with “yum install unix2dos dos2unix”.
- Notepad++ EOL Conversion with screen shots (Tech-Tips Blog)