1dos2unix(1)                       2010-08-18                       dos2unix(1)
2
3
4

NAME

6       dos2unix - DOS/MAC to UNIX and vice versa text file format converter
7

SYNOPSIS

9           dos2unix [options] [-c CONVMODE] [-o FILE ...] [-n INFILE OUTFILE ...]
10           unix2dos [options] [-c CONVMODE] [-o FILE ...] [-n INFILE OUTFILE ...]
11

DESCRIPTION

13       The Dos2unix package includes utilities "dos2unix" and "unix2dos" to
14       convert plain text files in DOS or MAC format to UNIX format and vice
15       versa.  Binary files and non-regular files, such as soft links, are
16       automatically skipped, unless conversion is forced.
17
18       Dos2unix has a few conversion modes similar to dos2unix under
19       SunOS/Solaris.
20
21       In DOS/Windows text files line endings exist out of a combination of
22       two characters: a Carriage Return (CR) followed by a Line Feed (LF).
23       In Unix text files line endings exists out of a single Newline
24       character which is equal to a DOS Line Feed (LF) character.  In Mac
25       text files, prior to Mac OS X, line endings exist out of a single
26       Carriage Return character. Mac OS X is Unix based and has the same line
27       endings as Unix.
28

OPTIONS

30       -c, --convmode CONVMODE
31           Set conversion mode. Where CONVMODE is one of: ascii, 7bit, iso,
32           mac with ascii being the default.
33
34       -f, --force
35           Force conversion of all files. Also binary files.
36
37       -h, --help
38           Display online help.
39
40       -k, --keepdate
41           Keep the date stamp of output file same as input file.
42
43       -L, --license
44           Display software license.
45
46       -l, --newline
47           Add additional newline.
48
49           dos2unix: Only DOS line endings are changed to two Unix line
50           endings.  In Mac mode only Mac line endings are changed to two Unix
51           line endings.
52
53           unix2dos: Only Unix line endings are changed to two DOS line
54           endings.  In Mac mode Unix line endings are changed to two Mac line
55           endings.
56
57       -n, --newfile INFILE OUTFILE ...
58           New file mode. Convert file INFILE and write output to file
59           OUTFILE. File names must be given in pairs and wildcard names
60           should NOT be used or you WILL lose your files.
61
62       -o, --oldfile FILE ...
63           Old file mode. Convert file FILE and overwrite output to it. The
64           program default to run in this mode. Wildcard names may be used.
65
66       -q, --quiet
67           Quiet mode. Suppress all warning and messages.
68
69       -V, --version
70           Display version information.
71

CONVERSION MODES

73       Conversion modes ascii, 7bit, and iso are similar to those of
74       dos2unix/unix2dos under SunOS/Solaris.
75
76       ascii
77           dos2unix: In this mode DOS line endings are converted to Unix line
78           endings.  Unix and Mac line endings are not changed.
79
80           unix2dos: In this mode Unix line endings are converted to DOS line
81           endings.  DOS and Mac line endings are not changed.
82
83           Although the name of this mode is ASCII, which is a 7 bit standard,
84           the actual mode is 8 bit.
85
86       mac dos2unix: In this mode Mac line endings are converted to Unix line
87           endings.  DOS and Unix line endigs are not changed. You can also
88           use the command "mac2unix" to run dos2unix in Mac mode.
89
90           unix2dos: In this mode Unix line endings are converted to Mac line
91           endings.  DOS and Mac line endigs are not changed. You can also use
92           the command "unix2mac" to run unix2dos in Mac mode.
93
94       7bit
95           In this mode DOS line endings are converted to Unix line endings or
96           vice versa.  All 8 bit non-ASCII characters (with values from 128
97           to 255) are converted to a space.
98
99       iso In this mode DOS line endings are converted to Unix line endings or
100           vice versa.  Characters are converted between the DOS character set
101           (code page) CP437 and ISO character set ISO-8859-1 on Unix. CP437
102           characters without ISO-8859-1 equivalent, for which conversion is
103           not possible, are converted to a dot. The same counts for
104           ISO-8859-1 characters without CP437 counterpart. CP437 is mainly
105           used in the USA. In Western Europe CP850 is more standard.
106
107           Another option to convert text files between different encodings is
108           to use dos2unix in combination with iconv(1). Iconv can convert
109           between a long list of character encodings. Some examples:
110
111           Convert from DOS DOSLatinUS to Unix Latin-1
112
113               iconv -f CP437 -t ISO-8859-1 in.txt | dos2unix > out.txt
114
115           Convert from DOS DOSLatin1 to Unix Latin-1
116
117               iconv -f CP850 -t ISO-8859-1 in.txt | dos2unix > out.txt
118
119           Convert from Windows WinLatin1 to Unix Latin-1
120
121               iconv -f CP1252 -t ISO-8859-1 in.txt | dos2unix > out.txt
122
123           Convert from Windows WinLatin1 to Unix UTF-8 (Unicode)
124
125               iconv -f CP1252 -t UTF-8 in.txt | dos2unix > out.txt
126
127           Convert from Windows UTF-16 (Unicode) to Unix UTF-8 (Unicode)
128
129               iconv -f UTF-16 -t UTF-8 in.txt | dos2unix > out.txt
130
131           Convert from Unix Latin-1 to DOS DOSLatinUS
132
133               unix2dos < in.txt | iconv -f ISO-8859-1 -t CP437 > out.txt
134
135           Convert from Unix Latin-1 to DOS DOSLatin1
136
137               unix2dos < in.txt | iconv -f ISO-8859-1 -t CP850 > out.txt
138
139           Convert from Unix Latin-1 to Windows WinLatin1
140
141               unix2dos < in.txt | iconv -f ISO-8859-1 -t CP1252 > out.txt
142
143           Convert from Unix UTF-8 (Unicode) to Windows WinLatin1
144
145               unix2dos < in.txt | iconv -f UTF-8 -t CP1252 > out.txt
146
147           Convert from Unix UTF-8 (Unicode) to Windows UTF-16 (Unicode)
148
149               unix2dos < in.txt | iconv -f UTF-8 -t UTF-16 > out.txt
150
151           See also <http://czyborra.com/charsets/codepages.html> and
152           <http://czyborra.com/charsets/iso8859.html>.
153

UNICODE

155       There exist different Unicode encodings. On Unix/Linux Unicode files
156       are mostly encoded in UTF-8 encoding. UTF-8 is ASCII compatible. UTF-8
157       files can have DOS, Unix or Mac line endings. It is safe to run
158       dos2unix/unix2dos on UTF-8 encoded files. On Windows mostly UTF-16
159       encoding is used for Unicode files. Dos2unix/unix2dos should not be run
160       on UTF-16 files. UTF-16 files are automatically skipped, because it are
161       binary files.
162

EXAMPLES

164       Read input from 'stdin' and write output to 'stdout'.
165
166           dos2unix
167           dos2unix -l -c mac
168
169       Convert and replace a.txt. Convert and replace b.txt.
170
171           dos2unix a.txt b.txt
172           dos2unix -o a.txt b.txt
173
174       Convert and replace a.txt in ascii conversion mode.
175
176           dos2unix a.txt
177
178       Convert and replace a.txt in ascii conversion mode.  Convert and
179       replace b.txt in 7bit conversion mode.
180
181           dos2unix a.txt -c 7bit b.txt
182           dos2unix -c ascii a.txt -c 7bit b.txt
183
184       Convert a.txt from Mac to Unix format.
185
186           dos2unix -c mac a.txt
187           mac2unix a.txt
188
189       Convert a.txt from Unix to Mac format.
190
191           unix2dos -c mac a.txt
192           unix2mac a.txt
193
194       Convert and replace a.txt while keeping original date stamp.
195
196           dos2unix -k a.txt
197           dos2unix -k -o a.txt
198
199       Convert a.txt and write to e.txt.
200
201           dos2unix -n a.txt e.txt
202
203       Convert a.txt and write to e.txt, keep date stamp of e.txt same as
204       a.txt.
205
206           dos2unix -k -n a.txt e.txt
207
208       Convert and replace a.txt. Convert b.txt and write to e.txt.
209
210           dos2unix a.txt -n b.txt e.txt
211           dos2unix -o a.txt -n b.txt e.txt
212
213       Convert c.txt and write to e.txt. Convert and replace a.txt.  Convert
214       and replace b.txt. Convert d.txt and write to f.txt.
215
216           dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt
217

LOCALIZATION

219       LANG
220           The primary language is selected with the environment variable
221           LANG. The LANG variable consists out of several parts.  The first
222           part is in small letters the language code. The second is optional
223           and is the country code in capital letters, preceded with an
224           underscore. There is also an optional third part: character
225           encoding, preceded with a dot. A few examples for POSIX standard
226           type shells:
227
228               export LANG=nl               Dutch
229               export LANG=nl_NL            Dutch, The Netherlands
230               export LANG=nl_BE            Dutch, Belgium
231               export LANG=es_ES            Spanish, Spain
232               export LANG=es_MX            Spanish, Mexico
233               export LANG=en_US.iso88591   English, USA, Latin-1 encoding
234               export LANG=en_GB.UTF-8      English, UK, UTF-8 encoding
235
236           For a complete list of language and country codes see the gettext
237           manual:
238           <http://www.gnu.org/software/gettext/manual/gettext.html#Language-Codes>
239
240           On Unix systems you can use to command locale(1) to get locale
241           specific information.
242
243       LANGUAGE
244           With the LANGUAGE environment variable you can specify a priority
245           list of languages, separated by colons. Dos2unix gives preference
246           to LANGUAGE over LANG.  For instance, first Dutch and then German:
247           "LANGUAGE=nl:de". You have to first enable localization, by setting
248           LANG (or LC_ALL) to a value other than "C", before you can use a
249           language priority list through the LANGUAGE variable. See also the
250           gettext manual:
251           <http://www.gnu.org/software/gettext/manual/gettext.html#The-LANGUAGE-variable>
252
253           For Esperanto there is a special language file in x-method format.
254           X-method can be used on systems that don't support Latin-3 or
255           Unicode character encoding.  Make LANGUAGE equal to "eo-x:eo".
256
257           If you select a language which is not available you will get the
258           standard English messages.
259
260       DOS2UNIX_LOCALEDIR
261           With the environment variable DOS2UNIX_LOCALEDIR the LOCALEDIR set
262           during compilation can be overruled. LOCALEDIR is used to find the
263           language files. The GNU default value is "/usr/local/share/locale".
264           Option "-V" will display the LOCALEDIR that is used.
265
266           Example (Windows Command Prompt):
267
268               set DOS2UNIX_LOCALEDIR=c:/my_prefix/share/locale
269

AUTHORS

271       Benjamin Lin - <blin@socs.uts.edu.au>
272
273       Bernd Johannes Wuebben (mac2unix mode) - <wuebben@kde.org>
274
275       Erwin Waterlander - <waterlan@xs4all.nl>
276
277       Project page: <http://www.xs4all.nl/~waterlan/dos2unix.html>
278
279       SourceForge page: <http://sourceforge.net/projects/dos2unix/>
280
281       Freshmeat: <http://freshmeat.net/projects/dos2unix>
282

SEE ALSO

284       iconv(1)
285
286
287
288dos2unix                          2010-07-23                       dos2unix(1)
Impressum