Version 0 of dos2unix

Updated 2003-04-25 16:49:46

GPS @ April 25 2003 - A dos2unix script is usually used to convert the end of line characters in text files from DOS/Windows format to a Unix-like format. Tcl can do automatic conversion of line endings, but I also need the conversion done in Windows, because I use xedit in Cygwin XFree86, so I came up with this short script.

 #!/bin/tclsh8.4

 foreach f $::argv {
        puts ${f}...
        set fd [open $f r]
        fconfigure $fd -translation binary
        set data [read $fd]
        close $fd

        set data [string map {"\r\n" "\n"} $data]

        set fd [open $f w]
        fconfigure $fd -translation binary
        puts -nonewline $fd $data
        close $fd
 }

There are also ways of doing this with the tr utility, sed, and probably others...