diffutils: Overview

1 
1 Overview
1 ********
1 
1 Computer users often find occasion to ask how two files differ.  Perhaps
1 one file is a newer version of the other file.  Or maybe the two files
1 started out as identical copies but were changed by different people.
1 
1    You can use the 'diff' command to show differences between two files,
1 or each corresponding file in two directories.  'diff' outputs
1 differences between files line by line in any of several formats,
1 selectable by command line options.  This set of differences is often
1 called a "diff" or "patch".  For files that are identical, 'diff'
1 normally produces no output; for binary (non-text) files, 'diff'
1 normally reports only that they are different.
1 
1    You can use the 'cmp' command to show the byte and line numbers where
1 two files differ.  'cmp' can also show all the bytes that differ between
1 the two files, side by side.  A way to compare two files character by
11 character is the Emacs command 'M-x compare-windows'.  ⇒Other
 Window (emacs)Other Window, for more information on that command.
1 
1    You can use the 'diff3' command to show differences among three
1 files.  When two people have made independent changes to a common
1 original, 'diff3' can report the differences between the original and
1 the two changed versions, and can produce a merged file that contains
1 both persons' changes together with warnings about conflicts.
1 
1    You can use the 'sdiff' command to merge two files interactively.
1 
1    You can use the set of differences produced by 'diff' to distribute
1 updates to text files (such as program source code) to other people.
1 This method is especially useful when the differences are small compared
1 to the complete files.  Given 'diff' output, you can use the 'patch'
1 program to update, or "patch", a copy of the file.  If you think of
1 'diff' as subtracting one file from another to produce their difference,
1 you can think of 'patch' as adding the difference to one file to
1 reproduce the other.
1 
1    This manual first concentrates on making diffs, and later shows how
1 to use diffs to update files.
1 
1    GNU 'diff' was written by Paul Eggert, Mike Haertel, David Hayes,
1 Richard Stallman, and Len Tower.  Wayne Davison designed and implemented
1 the unified output format.  The basic algorithm is described by Eugene
1 W. Myers in "An O(ND) Difference Algorithm and its Variations",
1 'Algorithmica' Vol. 1, 1986, pp. 251-266,
1 <http://dx.doi.org/10.1007/BF01840446>; and in "A File Comparison
1 Program", Webb Miller and Eugene W. Myers, 'Software--Practice and
1 Experience' Vol. 15, 1985, pp. 1025-1040,
1 <http://dx.doi.org/10.1002/spe.4380151102>.  The algorithm was
1 independently discovered as described by Esko Ukkonen in "Algorithms for
1 Approximate String Matching", 'Information and Control' Vol. 64, 1985,
1 pp. 100-118, <http://dx.doi.org/10.1016/S0019-9958(85)80046-2>.  Unless
1 the '--minimal' option is used, 'diff' uses a heuristic by Paul Eggert
1 that limits the cost to O(N^1.5 log N) at the price of producing
1 suboptimal output for large inputs with many differences.  Related
1 algorithms are surveyed by Alfred V. Aho in section 6.3 of "Algorithms
1 for Finding Patterns in Strings", 'Handbook of Theoretical Computer
1 Science' (Jan Van Leeuwen, ed.), Vol. A, 'Algorithms and Complexity',
1 Elsevier/MIT Press, 1990, pp. 255-300.
1 
1    GNU 'diff3' was written by Randy Smith.  GNU 'sdiff' was written by
1 Thomas Lord.  GNU 'cmp' was written by Torbjo"rn Granlund and David
1 MacKenzie.
1 
1    GNU 'patch' was written mainly by Larry Wall and Paul Eggert; several
1 GNU enhancements were contributed by Wayne Davison and David MacKenzie.
1 Parts of this manual are adapted from a manual page written by Larry
1 Wall, with his permission.
1