Learn the 'unix2dos' Linux Command

Change a text file to a DOS-compatible format

The unix2dos command converts the format of text files from a Unix format to a DOS format.

Format Incompatibility

By default, the end of every line of a plain-text file in Linux ends with a special linefeed character. However, in the Windows world—with its origins in the Microsoft MS-DOS operating system—every plain-text file ends with two special characters: a line feed plus a carriage return. So, although a plain-text file is cross-platform, files originating in Unix-based or Windows-based computers look different unless a conversion utility corrects for these special characters.

These special characters—called control characters—harken to the days of teletype machines or line printers, when the file to be printed required these characters to tell the device how to proceed. A line feed character advances to the next line of the output. A carriage return character returns the cursor or print head to the leftmost position. In Unix, LF implies CR; in DOS, and later in Windows, CR and LF specify separately.


The command takes the following general format:

unix2dos [-hkqV] [--help] [--keepdate] [--quiet] [--version] [-c convmode] [-o file ...] [-n infile outfile ...]


Modify the command using the following options:

  • -h --help: Print online help.
  • -k --keepdate: Keep the date stamp of the output file the same as the input file.
  • -q --quiet: Quiet mode. Suppress all warnings and messages.
  • -V --version: Prints version information.
  • -c --convmode convmode: Sets conversion mode. Simulates unix2dos under SunOS.
  • -o --oldfile file ...: Old file mode. Convert the file and write output to it. The program defaults to run in this mode. Wildcard names may be used.
  • -n --newfile infile outfile ...: New file mode. Convert the infile and write output to the outfile. File names must be given in pairs, and wildcard names should NOT be used or you WILL lose your files.