unix2dos

UNIX to Windows or MAC text file format converter.

Syntax
      unix2dos [options] [-c convmode] [-o file ...] [-n infile outfile ...]

Key
   -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
                    Set conversion mode.
                    Where convmode is one of: ASCII, 7bit, ISO, Mac with ASCII being the default.
                    Simulates dos2unix 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 outfile.
                    File names must be given in pairs and wildcard names should NOT be used or you WILL lose your files.

unix2dos converts plain text files in UNIX format to Windows or MAC format.

Later versions of dos2unix have additional options to add/remove Byte Order Marks (BOM) and handle alternate code pages.

Alternative using sed

sed -i -e 's/\r*$/\r/' file

Examples

Get input from stdin and write output to stdout:

unix2dos

Convert and replace a.txt. Convert and replace b.txt:

unix2dos a.txt b.txt
unix2dos -o a.txt b.txt

Convert and replace a.txt in ASCII conversion mode. Convert and replace b.txt in ISO conversion mode:

unix2dos a.txt -c iso b.txt
unix2dos -c ascii a.txt -c iso b.txt

Convert and replace a.txt while keeping original date stamp:

unix2dos -k a.txt
unix2dos -k -o a.txt

Convert a.txt and write to e.txt:

unix2dos -n a.txt e.txt

Convert a.txt and write to e.txt, keep date stamp of e.txt same as a.txt:

unix2dos -k -n a.txt e.txt

Convert and replace a.txt. Convert b.txt and write to e.txt:

unix2dos a.txt -n b.txt e.txt
unix2dos -o a.txt -n b.txt e.txt

Convert c.txt and write to e.txt. Convert and replace a.txt. Convert and replace b.txt. Convert d.txt and write to f.txt:

unix2dos -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt

“I never understood the point of juicing – I always thought I could get enough nutrients from eating fruit and vegetables – but now I’m a convert” ~ Thandiwe Newton

Related Linux commands

dos2unix - Windows to UNIX text file format converter.


 
Copyright © 1999-2024 SS64.com
Some rights reserved