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 logresolvemerge.pl, I had again this problem. The file logresolvemerge.pl included in the awstats package from Debian, needs cleaning up as showed by the error:
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 /. /usr /usr/bin /usr/bin/fromdos /usr/share /usr/share/man /usr/share/man/man1 /usr/share/man/man1/fromdos.1.gz /usr/share/doc /usr/share/doc/tofrodos /usr/share/doc/tofrodos/readme.txt.gz /usr/share/doc/tofrodos/copyright /usr/share/doc/tofrodos/changelog.Debian.gz /usr/bin/todos /usr/bin/unix2dos /usr/bin/dos2unix /usr/share/man/man1/todos.1.gz /usr/share/man/man1/unix2dos.1.gz /usr/share/man/man1/dos2unix.1.gz