Convert Text Files From DOS to Unix Format

Here’s a quick tip if you happen to use both Windows and *nix systems on a regular basis.

If you need to edit and move text files (such as HTML or PHP files) between systems then you need to convert them to ensure that their format new lines are created properly then you might find dos2unix (and unix2dos) as handy utilities.

New lines are handled different between DOS/Windows and Unix/Linux systems. There are invisible “control characters” that control how new lines are represented with an LF (or linefeed character) under UNIX/Linux operating systems and CR+LF (carriage return and line feed characters) under DOS/Windows operating systems.

For most people, you won’t need to worry about this particularly if you’re using an FTP application to transfer files between a local computer and a remote server as it takes car of this conversion for you but if you e-mail files or get at files through other means such as network shares then you might need to use dos2unix or unix2dos to do the text file conversion for you.

Leave a Reply

Your email address will not be published.