Linedif 1.06            Date: 22.01. 2005




WHAT IS linedif?
=================
Linedif is used to compare two text files, a reference file and a comparison
file. The comparison is made line by line, and can be used to compare a variety
of text files such as log files or emails.
You can make lots of different kinds of comparisons at once, and you can create
several target files at the same time, each of which could show deleted lines,
new lines, matching lines, or any combination thereof.

It will write new, deleted, or matching lines into a target file.
It is irrelevant where the differences are, as the files are sorted
internally before the comparison is made.

In order to perform several comparisons, linedif can be run from a CMD file.

Long and complex options can be set with a configuration file
(e.g. linedif.cfg)

Linedif will not process binary data. If you try, you will either get the
'file xx is empty' error message, or linedif will simply do nothing.


Limitations of linedif
======================
Overlapping can occur with files containing several identical lines. The
shorter the line length, the greater the chance that this will happen. linedif
will show the correct contents, but the wrong line numbers may be shown. Thus
linedif is of only limited use when comparing C source code, for example. In
such cases, I recommend tools such as PMDIFF, Guiffy, GNUdiff, ddif, and so
on....




INSTALLATION
============
Copy linedif.exe to any folder in the path.
Also keep this file, the file "Message" and the linedif.cfg file as a configuration template.


UNINSTALLING
============
Delete all the linedif related files.


GUARANTEE
=========
The Author accepts no liability for fitness of purpose, or damages
caused whether incidental, or consequential, by the use of this product,
howsoever caused. The end user has the sole responsability for any damage
caused.


LICENSE
=======
linedif is Freeware.


SYNTAX
======

From the command line:
----------------------
[x:\]linedif  file1 file2  targetfile  /switch targetfile /switch.......
The first switch will be associated with the first target file, the second
switch with the second target file, and so on.
Switches and target files can thus be in any order. The exception to this are
the general options.

file 1 = reference file
file 2 = comparison file

With a configuration file:
--------------------------
[c:\]linedif @ filename


Target files
============
The first switch will be associated with the first target file, the second
switch with the second target file, and so on.

Target files must not already exist unless you use the 'o' option.

Switch construction
===================

A switch always bgins with a / and is followed by one or more options.
The order in which the options are given is not important.

Individual options
------------------
These options can be used for each target file, and allow you to produce
several different target files at the same time.


a or A          Alphabetic sort, upper and lower case characters are taken into account.
                You cannot use the 'a' and 'n' options at the same time, as they are conflicting commands.
                Linedif will not recognise special symbols or accented characters.

n  or N         Numeric sort. The lines are output according to their line number in the original file.
                The option 'n' cannot be used with option 'a'.

l  or L         The line number is output.
                The line number is taken from the original file.

z or Z          New lines (only show lines in file 2 which are not in file 1).
                The option 'z' cannot be used with options w, b, g, t, 1 or 2.

w or W          Deleted lines (only show lines in file 1 which are not in file 2).
                The option 'w' cannot be used with options z, b, g, t, 1 or 2.

b or B          Show both new and deleted lines.
                The option 'b' cannot be used with options w, z, g, t, 1 or 2.

g or G          Show unchanged lines.
                The option 'g' cannot be used with options w, b, z, t, 1 or 2.

t or T          Show new, old and unchanged lines.
                The option 't' cannot be used with options w, b, g, z, 1 or 2.

s or S          Ignore blank lines and unprintable characters (spaces, etc) at the beginning of lines.

1               Only show file 1, use with options a, al, nl, r, or s.
                The option '1' cannot be used with options w, b, g, t, z or 2.

2               Only show file 2, use with options a, al, nl, r, or s.
                The option '2' cannot be used with options w, b, g, t, 1 or z.

+, h or H       Mark the new lines with ++ and the deleted lines with --.
                Use only with option b or t.

r or R          The Output is in reverse order.
                When used with option 'a' the lines will run from "z" to "A".
                When used with option 'n' the highest line number comes first.

o or O          If the  target file exists it will be overwritten.
                The option 'o' can be used in combination with any other option.


Global options
--------------

These global options are used only once and for all data sources. They remain
the same for all calculations and target files. They are set before any
comparisons are made.

If you want to apply different global options for different target files, for example deleting
additional empty lines, you must call linedif twice!

/DT             Delete Tab's. Tabs get converted into spaces.
                OneTAB gets converted into one space.

/DS             Delete Space.
                Two or more spaces get converted into a single space.
                Spaces at the start of a line are deleted.

/DL             Delete lines.
                Two or more empty lines get converted into a single empty line.

/HE             The file header ends with an empty line. This header is
               ignored and only lines afer the empty line are processed.
               The file header is not copied to the tartget file.
               If only one source file has a header, the results are likely to be wrong.

/HE:text        The file header ends with a character or character sequence.
/HE: text       Everything from the character sequence to the end of the line is a
                comment following after the header.
                Processing starts on the next line after the character sequence.
                You are allowed a single space between the colon and the character sequence.
                The character sequence itself must not contain spaces.
                Characters after the the character sequence but on the same line are ignored.
                If only one source file has a header, the results are likely to be wrong.

/HEL:text       The file header ends with a line that begins with a distinctive
/HEL: text      character or character sequence. Spaces in front of the character or character sequence are ignored.
                You are allowed a single space between the colon and the character sequence.
                The character sequence itself may not contain spaces.
                If only one source file has a header, the results are likely to be wrong.

/HR1            The header from file 1 (the reference file) is copied to every target file.
                As the target file could contain data from file2, adding
                the header from file1 may not be appropriate.

/HR2            The header from file 2 (the comparison file) is copied to every target file.
                As the target file could contain data from file1, adding
                the header from file2 may not be appropriate.

/HRF1 x:\file  The header from file 1 (the reference file) is copied to a destination path such as 'x:\file'.
                 Important: you must put a single space between HRF1 and the destination path.

/HRF2 x:\file  The header from file 2 (the comparison file) is copied to a destination path such as 'x:\file'.
                Important: you must put a single space between HRF2 and the destination path.

/I x:\file      The contents of the specified file are added after every entry.
                Important: Linedif starts inserting file on a new line.
                So in order to add an empty line, you just have to insert an empty file.
                Be careful, because Linedif will add the entire file, no matter how large!!
                If you specify the wrong insert file, you could end up with a very large target file,
                and if you try to edit it, it will take so long to load that only Ctrl+Alt+Del will get you out!!


/KL:text        Koment Line
/KL: text       A line that begins with this text is treated as a comment and is erased.
                The comment begins with a specific character or character sequence.
                You are allowed a single space between the colon and the character sequence.
                The character sequence itself must not contain spaces.

/KB:text        KB:A comment begins with this character or character sequence.
/KB: text       KE:A comment ends with this character or character sequence.
/KE:text        KB and KE must always be used as a pair.
/KE: text       Everything between /KB and /KE is erased.
                This kind of comment can go over several lines and need not start
                or end at a particular point on the line.
                Linedif will not add additional lines when a comment begins or ends in the middle of a line.

/KR:text        A comment begins with this character or character sequence, and ends at the end of the line.
/KR: text       The comment is erased, i.e. it is not added to the target file.
                The comment begins with a specific character or character sequence.
                You are allowed a single space between the colon and the character sequence.
                The character sequence itself must not contain spaces.

/M              Multiline
                Many lines are processed together. Many logfiles use several lines for a single event.
                Each event must be separated by an empty line. The line breaks are retained in the target file.

/M:text         Many lines are processed together. Many logfiles use several lines for a single event.
/M: text        Each event is separated by the given character or character sequence.
                You are allowed a single space between the colon and the character sequence.
                The line breaks are retained in the target file.

/M#:n           Many lines are processed together. The number of lines to treat as one are specified by 'n'.
                Some logfiles always consist of a fixed number of lines per entry, regardless if
                one or two lines are empty



Option combinations
=============

/z  /zl /w /wl  /g /gl /b /bl /b+ /bl+ /t /tl /t+ /tl+ /az /aw /ag /ab /at /ab+
/at+ /azl /awl /agl /abl /abl+ /atl /atl+ /nz /nw /ng /nb /nb+ /nt /nt+ /nzl
/nwl /ngl /nbl /nbl+ /ntl /ntl+ /a1 /a1l /a2 /a2l /n1l /n2l
All combinations can also be used with the options s, r  and  o


EXAMPLES:
=========
[C:\]linedif c:\April.txt  c:\May.txt c:\difference.txt  /ab

Compare April.txt and May.txt, find the new and deleted lines, write the result
to difference.txt in alphabetical order

[C:\]linedif member91.txt member2000.txt newmember.txt /azl /nbhlso lost.txt

Compare member91.txt and member2000.txt.
  1. Write new entries to newmember.txt
  2. Write new and deleted lines to lost.txt:
       - The output is in number order
       - The lines have a line number
       - New entrys are marked with "++" and deleted lines are marked with "--"
       - Empty lines and spaces before the first character are ignored
       - Overwrites the file lost.txt if it already exists

The Configuration File:
=======================
This must be a plain ASCII text file.
Filenames containing space characters such as NEW DATA.TXT must be in quotemarks as "NEW DATA.TXT".
The asterisk character * denotes a comment.  Everything after it until the end of line is a comment.
linedif does not care about the filenames or extensions used for either the configuration file or
the destination files. See also the linedif.cfg file, which you can use as an example to create
any number of different configuration files.

FAQ
===
Must I specify a comparison file(file2)?
Yes. Even when I only want to sort the reference file(file1).
This is true for the configuration file as well.
Linedif cannot know, if you wish to sort the reference file,
or if you have forgotten the comparison file and target files.

The commandline call for a sort would look like this:
[C:\]linedif file1 file1 file1.new /a1so


After the comparison file, must I enter the target file, or the switches?
It makes no difference, as linedif will evaluate the sequence of target files
and switches so that the first set of switches fit with the first target file,
the second with the second, and so on. Note that general options can occur
amongst any set of switches (or on their own) as they apply to all the files.

What size of files can I process with linedif?
Up to 1 million lines, and up to approximately 90Mb.

After a sort, I get an empty file. Why?
Empty lines are sorted to the top of the file, so the file can look
empty, but the text is futher down.

Will linedif overwrite existing files ?
No, linedif will halt unless you specify the 'o' option.

Why?
Because I believe it is safer to force you to delete the target files first,
rather than simply overwriting something you may need to keep.

Why the strange syntax?
This enables you to process the source files in a number of different ways
at the same time. Otherwise, you would have to restart linedif with new options
for every kind of operation you wish to perform.


Changes in 1. 06
=================
    Added general options.
    Improved error handling.


To do
======
Improved error handling.
Bether dokumentation.


SPECIAL NOTICE
==========
Many thanks go especially to
Cornelis Bockemuehl - programming
Peter Skye - upload and Translation
Peter Koller - Translation and suggestion for improvement to the next dokumentation.



Author
-----
Fritz Schori
Riedmatt 10
6300 Zug Schweiz
fritz@os2force.ch

Bug reports und wish-lists are welcome.

