[Author] [ChangeLog] [Contribute] [Contributors] [Copying] [Description] [Download] [Installation] [News] [Requirements] [Todo] [Usage]
Peter Hanecak <hany (at) hany.sk>
Thanks to contributors:
And thanks also to suggestions from:
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 GNU 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 http://freshmeat.net/projects/popt/. Sources can be downloaded from ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/. RPM package of mktemp can be found for example at http://rpmfind.net/linux/RPM/popt.html.
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 alredy installed.
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:
$ ./configure
$ make
$ 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
If you want to build optimized hd2u binary using profile-directed
optimizations (gcc's -fprofile-arcs
and
-fbranch-probabilities
options) use:
$ make dos2unix-optimized
dos2unix [--verbose|-v] [--test|-t] [--force|-f] [--<x>2<y>|--auto|-<Z>] [<file name> [...]] | ||
--auto , -A |
output will be set based upon autodetection of source format | |
--d2u , -U |
perform DOS -> UNIX conversion | |
--m2u , -T |
perform MAC -> UNIX conversion | |
--u2d , -D |
perform UNIX -> DOS conversion | |
--u2m , -M |
perform UNIX -> MAC conversion | |
--d2m , -O |
perform DOS -> MAC conversion | |
--m2d , -C |
perform MAC -> DOS conversion | |
--force , -f |
suppress internal conversion type corrections based on autodetected input format | |
--skipbin , -b |
skip binary files | |
--test , -t |
don't write any conversion results; usefull with --verbose
to just report on source type |
|
--verbose , -v |
print extra information on stderr | |
--version , -V |
print version information on stderr |
When no options are given then input format will be automatically detected and converted as follows:
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 (--d2u
or --u2d
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 --skipbin
(or -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
'dos2unix --help
'.
Examples:
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
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
This stable release contains following changes since last stable release:
Peter Hanecak <hany (at) hany.sk>
This stable release contains following changes since last stable release:
b
' to 'fopen()
' calls so that conversion
is not confused on platforms like CygwinPeter Hanecak <hany (at) hany.sk>
This stable release contains no functional changes since last stable release. Changes are related only to build provess:
'make test
'
'make dos2unix-optimized
'
Peter Hanecak <hany (at) hany.sk>
This stable release contains no functional changes since last development release (0.9.2). Only few typos in documentation has been fixed.
Most notable changes since last stable release (0.8.2) are:
Peter Hanecak <hanecak (at) megaloman.sk>
In this release issues with some binary files being recognized as text files in Macintosh format should be resolved. Also documentation has been enhanced and some typos in it fixed.
Peter Hanecak <hanecak (at) megaloman.sk>
New --version
(-V
) option has been added to display version information and
build process has been enhanced.
Peter Hanecak <hanecak (at) megaloman.sk>
This release starts development period. Most notable change is addition of support for Macintosh text format.
Peter Hanecak <hanecak (at) megaloman.sk>
This release introduces read/write buffers which increases conversion performance about 9 times.
Peter Hanecak <hanecak (at) megaloman.sk>
Temporary files are now created in directory defined by TMPDIR
or TMP
environment variable. If no such variable is found, '/tmp
' directory is
used. Also security has been enhanced by usage of 'mkstemp()
' instead of
'tmpnam()
'.
Peter Hanecak <hanecak (at) megaloman.sk>
This stable release consists of documentation updates and fixes.
Peter Hanecak <hanecak (at) megaloman.sk>
Compilation issues with gcc 2.96 were resolved and documentation has been fixed.
Peter Hanecak <hanecak (at) megaloman.sk>
In this release, there are following changes:
convert()
is reworked so it always "caches" input into tempfile (even
when no conversion is done *). This makes dos2unix able to convert data from
stdin again. Also scan/detect code has been separated from logic (conversion
type selection) and verbose output. Also every conversion type (dos -> unix,
unix -> dos, copy) has now its own optimised loop.
From above changes comes some performance issues (I do not know if anyone cares about them, but still I'm going to write about it):
--test
and --verbose
, --test
alone makes
just file reads without any output) temporary file is used to store
input - this is because I did not wanted to slow scan with condition
'if (!testmode)
' on each 'fputc()
' thus slowing conversion; I think
test will be used much less then conversionsAs opposed to version 0.7.0, binary files are skipped only when --skipbin
or -b
option is used. I'm from Slovakia and our charset uses codes above
126 thus all our conversion which uses dos2unix 0.7.0 wont work on such
files. So to maintain some backward compatibility from now binary files will
be detected but not skipped by default.
By the way, if you are using 'dos2unix *
' you should be VERY CAREFULL!!! It's
something like 'rm -rf .
' if missused. So 'dos2unix *.txt *.c *.h doc/*.html
'
would be far better (even if not that comfortable).
Rouge '\r
' characters (DOS format line breaks with missing '\n
' after
them) are now reported but affected only by 'dos -> unix' conversion - they
are skipped.
If you give directory as input file to 'dos2unix
' it will be skipped (I
have better no idea what it was doing untill now).
Peter Hanecak <hanecak (at) megaloman.sk>
This is development release based on changes from Rob Ginda <rginda (at) netscape.com> which breaks conversion functionality when converting data from stdin. So users which requires proper functionality of stdin conversion should continue to use version 0.6.0 (or earlier) and wait for fixed version to be released (or make a fix for themselves - in such case I would be happy to receive that fix :).
Peter Hanecak <hanecak (at) megaloman.sk>
1.0.3 | 2008/09/10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2007/09/28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1.0.2 | 2007/08/28 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2007/07/05 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2007/01/28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1.0.1 | 2007/01/28 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2006/08/17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2006/05/13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2005/10/03 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1.0.0 | 2005/03/15 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0.9.2 | 2004/10/28 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
2004/10/25 | |
2004/04/18 | 0.9.1 |
2004/04/14 | 0.9.0 |
2003/11/14 | 0.8.2 |
2003/10/03 | 0.8.1 |
2003/02/26 | 0.8.0 |
2002/05/07 | 0.7.2 |
2002/01/04 | 0.7.1 |
2001/01/11 | 0.7.0 |
2001/02/11 | 0.6.0 |
2001/01/21 | 0.5.12 |
2000/10/03 | 0.5.11 |
2000/09/26 | 0.5.10 |
2000/08/07 | 0.5.9 |
2000/08/05 | 0.5.0 |
1999/11/25 | |