The Journal Of A Linux Sysadmin

Install Dos2unix on Debian

| Comments

DOS text files traditionally have carriage return and line feed pairs as their newline characters, while Unix text files have the line feed as their newline character. I often find myself needing to ‘clean-up’ some files saved with Win/DOS characters, and this can be done very easy with dos2unix. While RedHat based Linux distributions will traditionally include these small utils by default, on Debian I have to install them if needed.

For example, just today while I was working on an awstats project and needed to use the contributed file, I had again this problem. The file included in the awstats package from Debian, needs cleaning up as showed by the error:

-bash: /usr/share/doc/awstats/examples/ /usr/bin/perl^M: bad interpreter: No such file or directory 

The dos2unix and corresponding unix2dos (even if I have never used this), are found in the tofrodos Debian package, and to install the package just type:

apt-get install tofrodos

Once I have dos2unix installed, I can use it to clean up very easy any file that needs that:


and the offending DOS characters are gone.

Check out the manual page for full details on the usage of these little tools.

The list of files included in the tofrodos package:

dpkg -L tofrodos