compares the file named dog that is in the /tmp directory, with the file dog in the current directory.
The normal output contains lines of these forms:
n1 a n3,n4
n1,n2 d n3
n1,n2 c n3,n4
These lines resemble ed commands to convert file1 into file2. The numbers after the letters pertain to file2. In fact, by exchanging a for d and reading backward, one can find out in just the same way how to convert file2 into file1. As in ed, identical pairs where n1 = n2 or n3 = n4 are abbreviated as a single number.
Following each of these lines come all the lines that are affected in the first file flagged by ``<'', then all the lines that are affected in the second file flagged by ``>''.
diff recognizes block and character special files and FIFOs, and will not attempt to diff these files against regular files.
If both file1 and file2 are directories, there
are a number of possible messages that diff might
generate. If a file only occurs in one directory, a message, as in
the following example, will be displayed:
diff /u/nigel/devices /dev
Only in /u/nigel/devices: rfd01
where /u/nigel/devices is the directory pathname and
rfd01 is the filename present only in
/u/nigel/devices. If a filename is common to each
directory, but the two files are of different types, a message such
as the following will be displayed:
diff /u/nigel/devices /dev
File /u/nigel/devices/rfd01 is a regular file while file /dev/rfd01
is a character special file
diff recognizes the following options:
This script works by performing a sequence of editing operations on an original ancestral file. Specify this file as the first argument ($1) to the script. Subsequent arguments ($2,$3, ... are a sequence of ed scripts. These scripts are presumed to have been created in the order given on the command line.
The command to create the scripts is:
diff -e file_N file_N+1 > del_N
ed can recreate the N+1th version of
file_1 from the Nth version file_N
using the ed commands in del_N:
(cat del_N; echo '1,$p') | ed - file_N > file_N+1
Similarly, the command to recreate the fifth version
(file_5) from the ancestral file would be:
(cat del_1 del_2 del_3 del_4; echo '1,$p') | ed - file_1 > file_5
ed takes the commands from each del_ file, performs them on the ancestral file file_1, and writes the desired version to file_5.
The version of patch provided by The Santa Cruz Operation, Inc. can understand both context formats.
The -e and -f options cannot be used with the -h option.
Editing scripts produced under the -e or -f option do not always work correctly on lines consisting of a single dot ``.''.
ISO/IEC DIS 99452:1992, Information technology Portable Operating System Interface (POSIX) Part 2: Shell and Utilities (IEEE Std 1003.21992);
AT&T SVID Issue 2;
X/Open CAE Specification, Commands and Utilities, Issue 4, 1992.