Go to ...

Techpository

A Better Technical Repository

RSS Feed

Linux: dos2unix and unix2dos


The big question is why would you want to use unix2dos in this world of modern and advanced software?

In general the answer is you probably do not, but in some cases you might.

One key area it could quickly help is if you are working in a Linux environment that does not have X Windows.

If you open a document file that was created in Windows there is a fair chance that it look something like this:

cat test.txt
This is a test file^M
That contains the annoying mark up language^M
That works well inWindows, but not so much in Linux^M

User the command dos2unix test.txt will get you the following results:
cat test.txt
This is a test file
That contains the annoying mark up language
That works well inWindows, but not so much in Linux

unix2dos will add the carriage returns back.

Not a huge deal, but can help in a pinch sometimes.