Unix2dos is a utility that can convert the newline endings between Unix like systems (Linux, MacOS, BSD, etc.) that uses \n and DOS like systems (DOS, FreeDOS, Windows) that uses \r\n.

The conversion is necessary when dealing with files across these two platforms where the new line endings are important such as when dealing with scripts.

Conversion[edit | edit source]

On Linux, use any one of:

## From \r\n to \n:
$ dos2unix
$ cat file.txt | tr -d '\r' > file2.txt

## From \n to \r\n:
$ unix2dos