Learn the Linux Command - unix2dos

Change a text file to a DOS-compatible format

Software programmer working at computer

Reza Estakhrian / Getty Images

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 Microsoft's 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 will 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.

Synopsis

The command takes the following general format:

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

Options

Modify the command using the following options:

  • -h --help: Print online help.
  • -k --keepdate: Keep the date stamp of output file same as input file.
  • -q --quiet: Quiet mode. Suppress all warning 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 default to run in this mode. Wildcard names may be used.
  • -n --newfile infile outfile ...: New file mode. Convert the infile and write output to outfile. File names must be given in pairs and wildcard names should NOT be used or you WILL lost your files.