Text End-of-Line (EOL) Conversion

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”.

Related Articles:

About notesbytom

Keeping technology notes on WordPress.com to free up my mind to solve new problems rather than figuring out the same ones repeatedly :-).
This entry was posted in Linux, System Administration, Uncategorized and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s