Hany's Home Page
Hany's Dos2Unix 0.9.2 (development release)
Peter Hanecak <hany (at) hany.sk>
- Sam Barnum <sbarnum (at) pointsystems.com>
for suggestion about support for Macintosh text file format
- Rob Ginda <rginda (at) netscape.com>
rewrite of version 0.6.0 and new features (--test, --verbose, skip binary)
- Dan Kuykendall <dan (at) kuykendall.org>
suggestion to not to touch files which are alredy in specified target format
for suggestion and code changes hints about support for Macintosh text file
format and also for pushing me to actualy do that :)
- Philip White <pwhite (at) gigacluster.net>
minor grammar corrections and miscellaneous beautifying in help & docs
hd2u is Hany's DOS <-> Unix convertor.
dos2unix is filter used to convert plain texts from DOS (CR/LF) format to UNIX
format (LF) and vice versa. Aditionaly it can also handle files in Macintosh
format (CR) and convert them into other formats.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
See the COPYING file or
General Public License page for license information.
Copyright 1997,.. by Peter Hanecak <hany (at) hany.sk>.
All rights reserved.
Popt library is required to process command line arguments.
For more information about mktemp see
Sources can be downloaded from
RPM package of mktemp can be found for example at
You can find sources at:
Also you can download RPM packages from:
First, you need some UNIX system which have some basic C development tools
Note: If you're using some package management tool on your system you should
have also installed so called 'development' package of popt library
(popt-dev or popt-devel, etc.) so required header files are also installed.
After you sucessfuly downloaded and unpacked source tarball, do the
following in source directory:
$ make install
This will build and install '
dos2unix' into default location,
which is /usr/local/bin .
If you want to use another prefix than /usr/local use for example:
$ ./configure --prefix=/usr
This will install '
dos2unix' into /usr/bin .
For more information use:
$ ./configure --help
dos2unix [--verbose|-v] [--test|-t] [--force|-f] [--<x>2<y>|--auto|-<Z>] [<file name> [...]]
||output will be set based upon autodetection of source format
||perform DOS -> UNIX conversion
||perform MAC -> UNIX conversion
||perform UNIX -> DOS conversion
||perform UNIX -> MAC conversion
||perform DOS -> MAC conversion
||perform MAC -> DOS conversion
||suppress internal conversion type corrections based on autodetected input format
||skip binary files
||don't write any conversion results; usefull with
to just report on source type
||print extra information on stderr
||print version information on stderr
When no options are given then input format will be automatically detected
and converted as follows:
- DOS -> UNIX
- MAC -> UNIX
- UNIX -> DOS
Same as above applies if
--auto option is used.
When no file is given, then stdin is used as input and
stdout as output.
When concrete conversion type is used (
option) and file format is autodetected as target format, file is skipped - not
touched - so there is no modification time change.
Binary files will be skipped automatically if option
-b) is used.
Stray '\r' characters (without a following '\n') are reported but only
conversion 'DOS -> Unix' affects them (they are skipped).
You can display usage information using '
dos2unix -h' or
this converts README.txt into DOS format; if README.txt is in UNIX format,
it is converted otherwise it will be unchanged:
dos2unix --u2d README.txt
this is obvious :) :
cat source_in_UNIX_format.txt | dos2unix > result_in_DOS_format.txt
this will just "copy" source.txt to unchanged_source.txt:
cat source.txt | dos2unix | dos2unix > unchanged_source.txt
this will convert all .txt files in current directory into UNIX format,
all documents in UNIX format and all binary files are skipped, verbose
information will be displayed:
dos2unix -Ubv *.txt
How to contribute
If you would like to submit a patch, send it to me
<hany (at) hany.sk>.
Please be sure to include a textual explanation of what your patch does.
The preferred format for changes is '
diff -u' output. You might
generate it like this:
$ cd hd2u-work
$ [your changes]
$ make mrproper
$ cd ..
$ diff -urN hd2u-orig hd2u-work > mydiffs.patch
- NEWS: updated
- dos2unix.c: do not clear
FT_BINARY flag from
fileType when Mac
line endings are detected which should avoid image or sound (or
other binary) files to be confused with Mac text files (thanks to
basic <basic (at) mozdev.org> and Caj Nordström
<caj.nordstrom (at) beamex.com> for pointing out the bug and suggesting
- README: fixed typo (thanks to N. Roeser <n-roeser (at) gmx.net> and
Ryan Schmidt <hello-200407 (at) ryandesign.com> for pointing out the
- INSTALL: added notice about popt-devel as suggested by max
- install-sh: updated from automake-1.8.3 package
- Makefile.in: changed '
$(CC) $(CFLAGS) -o $(TARGET) $(TARGET).c
$(LIBS)' to '
$(CC) $(CFLAGS) -o $@ $(@:%=%.c) $(LIBS)' (based on
suggestion by Marty Leisner <mleisner (at) eng.mc.xerox.com>)
- ChangeLog, README: fixed typos
- Makefile.in: 'make cleanall' removes also cache directory created
-V) option added: display version
- configure.in: incorporated changes sugested by configure.scan
generated by 'autoscan'
- config.h.in added (as created by 'autoheader')
- configure.in: config.h is generated by 'configure'
- Makefile.in: incorporated changes done to configure.in
- README: added info about
- dos2unix.c: files in Mac format are now recognized; thanks to Sam
Barnum <sbarnum (at) pointsystems.com>
for suggestion (and to max also for pushing me to actualy do that :)
- dos2unix.c: new conversion types: MAC -> UNIX, UNIX -> MAC, DOS -> MAC and MAC -> DOS
- dos2unix.c: when autodetected input format does not match input
format suggested by conversion type option on command line, conversion
type is automaticaly corrected
-f) option, which supress above mentioned
- install-sh: updated from automake-1.6 package
- README: updated
- TODO: what should be fixed till next stable release
- dos2unix.c: read/write buffers implemented - increases performance
about 9 times
- dos2unix.c: message "File format '<file>':" changed to
"File format of '<file>':"
- TODO: updated
- dos2unix.c: mkstemp() used instead of tmpnam()
- dos2unix.c: temporary directory specified by TMPDIR or TMP
environment variable used; if none of them is avialable, then "/tmp"
- ChangeLog: fixed typo
- README: updated "Usage" chapter
- dos2unix.c: updated help
- applied patch from Philip White <pwhite (at) gigacluster.net>
(minor grammar corrections and miscellaneous beautifying in help & docs)
- INSTALL: fixed info about changing prefix
- Makefile.in: create bin directory before installing hd2u binary
into it; this should solve the problem when using custom prefix
in which 'bin' directory does not exists (thanks to Emanuele Olivetti
<olivetti (at) itc.it> for reporting the problem)
- dos2unix.c: fix gcc 2.96 warning: string length '687' is greater
than the minimum length '509' ISO C89 is required to support
- dos2unix.c: --skipbin (-b) switch added: binary files won't be
- dos2unix.c: --test (-t): NO output (not even verbose)
- dos2unix.c: conversion of input data from stdin works again
- dos2unix.c: reworked convert(): conversion of input data from stdin works
again; better separation of detection, verbose info output and other logic
- dos2unix.c: rouge '\r' are reported but only conversion dos -> unix
affects them (they are skipped)
- dos2unix.c: directories when given as input are skipped
- dos2unix.c: more robust source format detection can detect binary
files, mixed mode files, and files with no line endings at all
- dos2unix.c: added automatic skipping of binary files
- dos2unix.c: added --test mode to check filetype without converting
- dos2unix.c: added --verbose option to show status messages while
- dos2unix.c: converted C++ style (//) comments to C style (/**/)
(some C compilers will choke on //)
- dos2unix.c: reordered function definition to avoid prototypes
- dos2unix.c: replaced hard tabs with 4 spaces
- dos2unix.c: added emacs modeline
(2001/02/07 - Rob Ginda <rginda (at) netscape.com>)
- documentation updates (see TODO!!!)
- documentation: fixed typos
- dos2unix.c: handle NULL when returned by tmpnam()
- Makefile.in: added '-Wall -pedantic' to CFLAGS
- documentation extended (popt) and updated (configure)
- configure.in: check for getopt_long() function
- ./configure.in: check popt library
- Makefile.in: LIBS
- --auto option
- do not touch files which are alredy in specified target format
- first public release
- full enought feature set
- sometimes some BIG files are truncated - FIX THAT; it may be becase of
dos2unix' unable to handle big files or b) some weird character in input
files or both (reported are incidents: files over 1 GB and truncation of
one file from 6.4 MB to 2.5 MB)
- some other package formats to support more distributions