Convert DOS and Windows line breaks to Unix line breaks

Posted by skreuzer in UNIX

These one liners will convert a file with DOS (or windows) line breaks to a file with Unix line breaks

DOS/Windows to Unix:

tr -d '\15\32' < dosfile.txt > unixfile.txt

Under Solaris this will work as well:

dos2unix dosfile.txt unixfile.txt

The Conversation

Follow the reactions below and share your own thoughts.

  • Hollister

    That doesn’t work either…it just deletes all the “R” characters.

    You need to escape the CR and make it global. This works better:

    sed -i ‘s/rn/n/g’ file.txt