diffutils: Comparing Directories

1 
1 4 Comparing Directories
1 ***********************
1 
1 You can use 'diff' to compare some or all of the files in two directory
1 trees.  When both file name arguments to 'diff' are directories, it
1 compares each file that is contained in both directories, examining file
1 names in alphabetical order as specified by the 'LC_COLLATE' locale
1 category.  Normally 'diff' is silent about pairs of files that contain
1 no differences, but if you use the '--report-identical-files' ('-s')
1 option, it reports pairs of identical files.  Normally 'diff' reports
1 subdirectories common to both directories without comparing
1 subdirectories' files, but if you use the '-r' or '--recursive' option,
1 it compares every corresponding pair of files in the directory trees, as
1 many levels deep as they go.
1 
1    If only one file exists, 'diff' normally does not show its contents;
1 it merely reports that one file exists but the other does not.  You can
1 make 'diff' act as though the missing file is empty, so that it outputs
1 the entire contents of the file that actually exists.  (It is output as
1 either an insertion or a deletion, depending on whether the missing file
1 is in the first or the second position.)  To do this, use the
1 '--new-file' ('-N') option.  This option affects command-line arguments
1 as well as files found via directory traversal; for example, 'diff -N a
1 b' treats 'a' as empty if 'a' does not exist but 'b' does, and similarly
1 'diff -N - b' treats standard input as empty if it is closed but 'b'
1 exists.
1 
1    If the older directory contains large files that are not in the newer
1 directory, you can make the patch smaller by using the
1 '--unidirectional-new-file' option instead of '-N'.  This option is like
1 '-N' except that it inserts the contents only of files that appear in
1 the second directory but not the first (that is, files that were added).
1 At the top of the patch, write instructions for the user applying the
1 patch to remove the files that were deleted before applying the patch.
1 ⇒Making Patches, for more discussion of making patches for
1 distribution.
1 
1    To ignore some files while comparing directories, use the
1 '--exclude=PATTERN' ('-x PATTERN') option.  This option ignores any
1 files or subdirectories whose base names match the shell pattern
1 PATTERN.  Unlike in the shell, a period at the start of the base of a
1 file name matches a wildcard at the start of a pattern.  You should
1 enclose PATTERN in quotes so that the shell does not expand it.  For
1 example, the option '-x '*.[ao]'' ignores any file whose name ends with
1 '.a' or '.o'.
1 
1    This option accumulates if you specify it more than once.  For
1 example, using the options '-x 'RCS' -x '*,v'' ignores any file or
1 subdirectory whose base name is 'RCS' or ends with ',v'.
1 
1    If you need to give this option many times, you can instead put the
1 patterns in a file, one pattern per line, and use the
1 '--exclude-from=FILE' ('-X FILE') option.  Trailing white space and
1 empty lines are ignored in the pattern file.
1 
1    If you have been comparing two directories and stopped partway
1 through, later you might want to continue where you left off.  You can
1 do this by using the '--starting-file=FILE' ('-S FILE') option.  This
1 compares only the file FILE and all alphabetically later files in the
1 topmost directory level.
1 
1    If two directories differ only in that file names are lower case in
1 one directory and upper case in the upper, 'diff' normally reports many
1 differences because it compares file names in a case sensitive way.
1 With the '--ignore-file-name-case' option, 'diff' ignores case
1 differences in file names, so that for example the contents of the file
1 'Tao' in one directory are compared to the contents of the file 'TAO' in
1 the other.  The '--no-ignore-file-name-case' option cancels the effect
1 of the '--ignore-file-name-case' option, reverting to the default
1 behavior.
1 
1    If an '--exclude=PATTERN' ('-x PATTERN') option, or an
1 '--exclude-from=FILE' ('-X FILE') option, is specified while the
1 '--ignore-file-name-case' option is in effect, case is ignored when
1 excluding file names matching the specified patterns.
1 
1    To tell 'diff' not to follow a symbolic link, use the
1 '--no-dereference' option.
1