I was trying to hack an installation script this morning, and noted that VI was showing me Carriage Return/Line Feed symbols at the end of each line, indicating that the file had last been edited on a Windows platform using a tool such as Notepad.exe.
I can see this because each line ends with the special characters ^M which is the ASCII code for CR/LF.
In the past, I've always used the dos2unix command to strip these out of a file.
However, dos2unix no longer appears to be installed out-of-the-box with Ubuntu 10.04 or, worse still, available via the normal Canonical repositories; I tried installing it using the command: -
sudo apt-get install dos2unix
but got the "Computer says 'NO'" message of: -
E: Couldn't find package dos2unix
Googling around, I found this blog posting: -
http://mediakey.dk/~cc/dos2unix-on-ubuntu-and-debian/
which refers to a different package - tofrodos - which provides similar functionality.
I installed it using a similar command: -
sudo apt-get install tofrodos
accepting the warning that this package isn't certified as being an official part of Ubuntu.
Once done, I get two new commands: -
/usr/bin/todos
/usr/bin/fromdos
which equate to my old friends: -
dos2unix
unix2dos
respectively.
Sweet :-)
Thank you, I use very often dos2unix and I was really wondering it was! (I use it on the http://piwigo.org project to convert patch files send by contributors running on Windows.
ReplyDeletePierrick - glad to be of use :-)
ReplyDelete