dos2unix for poor basic unix

This entry is part 9 of 10 in the series Unix swissknife

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.

This entry was posted in English Content, Knowledgebase and tagged , , . Bookmark the permalink.