This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: "Unix2dos" – news · newspapers · books · scholar · JSTOR (November 2020) (Learn how and when to remove this template message)
unix2dos & dos2unix
Original author(s)John Birchfield
Developer(s)Benjamin Lin, Bernd Johannes Wuebben, Christian Wurll, Erwin Waterlander
Initial release1989; 33 years ago (1989)
Stable release
7.4.2 / October 12, 2020; 18 months ago (2020-10-12)
Operating systemUnix-like, DOS, OS/2, Windows
LicenseFreeBSD style license

unix2dos (sometimes named todos or u2d) is a tool to convert line breaks in a text file from Unix format (Line feed) to DOS format (carriage return + Line feed) and vice versa. When invoked as unix2dos the program will convert a Unix text file to DOS format, when invoked as dos2unix it will convert a DOS text file to UNIX format. [1]


Unix2dos and dos2unix are not part of the Unix standard. Commercial Unixes usually come with their own implementation of unix2dos/dos2unix, like SunOS/Solaris's dos2unix/unix2dos, HP-UX's dos2ux/ux2dos and Irix's to_unix/to_dos.

There exist many open source alternatives with different command names and options like dos2unix/unix2dos, d2u/u2d, fromdos/todos, endlines, flip.

See the manual page of the respective commands.

Alternatives to unix2dos conversion

Alternatives to dos2unix conversion

For the opposite conversion (dos2unix) it is possible to use, for example, the utility tr with the -d '\r' flag to remove the carriage return characters:

Note: The above method assumes there are only DOS line breaks in the input file. Any Mac line breaks (\r) present in the input will be removed.

An alternative to the dos2unix conversion is possible by using the col command that is available on Linux and other Unix-like operating systems, including Mac OS X. In the following case, InFile contains the undesired DOS (^M) line endings. After execution, OutFile is either created or replaced, and contains UNIX line endings. The -b option tells col not to output backspace characters.

$ col -b < InFile > OutFile

See also


  1. ^ A practical guide to Linux. Mark G. Sobell ISBN 0-13-147823-0 Page 55