Utility Assistance: dos2unix
I had known of the utility "dos2unix" for some time, but I never had occasion to use it until recently. I have been working on a script to assist in system administration, and had put in Yahoo! Briefcase so that I could access the single file on various systems. In the process, it got Windows formatting added in (open such a file in vim, for example, and you will see "^M" characters peppering each line). This causes no end of errors when the script is run on a linux system.
So, I thought I would try the dos2unix command I had read about. Command not found... sudo apt-get? Nope. Not in the repos. It turns out that the utility is called "tofrodos" (that's right, no "m") in the repos, with the added explanatory note "alias tofromdos". So I installed this, and tried to run "tofromdos". Not found.
After some searching, I found that once tofrodos is installed, you can run "dos2unix [filename]", and it runs as you would expect. I am still not sure why, but at least the utility is useable.
So, I thought I would try the dos2unix command I had read about. Command not found... sudo apt-get? Nope. Not in the repos. It turns out that the utility is called "tofrodos" (that's right, no "m") in the repos, with the added explanatory note "alias tofromdos". So I installed this, and tried to run "tofromdos". Not found.
After some searching, I found that once tofrodos is installed, you can run "dos2unix [filename]", and it runs as you would expect. I am still not sure why, but at least the utility is useable.
2 Comments:
Do you know about setting the file format in vim? If you do ":set ff=unix" and ":set ff=dos" in vim, you will respectively convert the file from whatever it was to UNIX line endings or DOS/Windows line endings (though why you would ever do the latter, I cannot imagine).
I did not know this, but will add it post haste! I assume it is added to .vimrc?
The utility is still handy for files that one does not need to open, just convert and then do whatever. But this setting will be a great addition.
Thanks!
Post a Comment
Subscribe to Post Comments [Atom]
<< Home