Thursday, March 02, 2006

sysutils on ubuntu

Since I occasionally have to deal with files authored on a windows machine, I have to deal with files that use both CR and LF at the end of every line. Instead of the standard linux line feed. In vim it comes out something like


Line 1 ^M
Line 2 ^M


If you need to convert a file like this. Just install sysutils in Ubuntu. It's just a collection of small programs, amongst them the programs dos2unix and unix2dos. Just run them with the file you want to convert as an argument and it will deal with the conversion of those carriage returns for you.

dos2unix dostext.txt

unix2dos unixtext.txt

Enjoy. By the way gedit can automatically detect whether a document is formatted for dos or not and deal with it intelligently. So can vim too most of the time. It's autodetection doesnt always work though.

0 Comments:

Post a Comment

<< Home