dos2unix for poor basic unix

Do you have cygwin base install right? So no dos2unix…you can convert a windows file to unix format with a small tr command like

tr -d '\15\32' < winfile.txt > unixfile.txt
I prefer the awk way of life:
awk '{ sub("\r$", ""); print }' winfile.txt > unixfile.txt
awk 'sub("$", "\r")' unixfile.txt > winfile.txt

See also the bash secret power addendum.

Leave a Reply