Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cmp(1)

comm(1)

ed(1)



DIFF(1)                   DOMAIN/IX SYS                   DIFF(1)



NAME
     diff - differential file comparator

USAGE
     diff [ -efbh ] file1 file2
     diff [ -efbh ] dir1 dir2

DESCRIPTION
     Diff tells what lines must be changed in two files to bring
     them into agreement.  If you specify a dash (-) in place of
     file1 (file2), it reads from the standard input.  If file1
     (file2) is a directory, diff searches a file in that direc-
     tory with the name file2 (file1).

     The normal output of diff contains lines which look similar
     to this:

          n1 a n3,n4
          n1,n2 d n3
          n1,n2 c n3,n4

     These lines resemble ed(1) commands to convert file1 into
     file2.  The a stands for add, the d for delete, and the c
     for change.  The numbers after the letters a, b, and c per-
     tain to file2.  In fact, by exchanging a for d and reading
     backward one may ascertain equally how to convert file2 into
     file1.  Identical pairs, where n1 = n2 or n3 = n4, are
     abbreviated as a single number.

     Following each of these lines are all the lines affected in
     the first file (flagged by <), then all the lines affected
     in the second file (flagged by >).

     Except in rare circumstances, diff finds the smallest suffi-
     cient set of file differences.

OPTIONS
     -b        Ignore trailing blanks (spaces and tabs) and com-
               pare other strings of blanks as equal.

     -e        Produce a script of a, c, and d commands for the
               text editor ed which will recreate file2 from
               file1 . In connection with -e, the following Shell
               program may help maintain multiple versions of a
               file.  Only an ancestral file ($1) and a chain of
               version-to-version ed scripts ($2,$3,...) made by
               diff need be on hand.  A ``latest version''
               appears on the standard output.  The Shell program
               is:




Printed 12/4/86                                            DIFF-1







DIFF(1)                   DOMAIN/IX SYS                   DIFF(1)



               (shift; cat $*; echo '1,$p') | ed - $1

     -f        Produce a script similar to the one created by the
               -e option, but in the opposite order.

     -h        Produce a quick comparison of specified files or
               directories.  Works only when changed stretches
               are short and well-separated, but does work on
               files of unlimited length.  Options -e and -f are
               unavailable with this option.

CAUTIONS
     Editing scripts produced by using the -e or -f option are
     naive about creating lines consisting of a single period
     (.).

FILES
     /tmp/d?????
      /usr/lib/diffh  (for -h)

DIAGNOSTICS
     Exit status is 0 for no differences, 1 for some differences,
     and 2 for trouble.

     ``Missing newline at end of file X'' indicates that the last
     line of file X did not have a newline.  If the lines are
     different, they will be flagged and output, although the
     output will seem to indicate they are the same.

RELATED INFORMATION
     cmp(1), comm(1), ed(1).






















DIFF-2                                            Printed 12/4/86





Typewritten Software • bear@typewritten.org • Edmonds, WA 98026