218Chapter7 • Miscellaneous Tools
7.3.1Other Forms of diff Utility
There are two other important forms of the
diff
utility. These are
diff3
and
sdiff
.
The
diff3
utility is used to compare three files and its general format is shown below.
diff3 [options] mine older yours
Suppose you and your colleague start working on a file simultaneously. The original file is
the
older
file. Now you have your copy of the file (the
mine
file) and your colleague has his own
copy of the file (the
yours
file). If you want to compare both of these modified copies of the file
with the original
older
file,
diff3
is a useful tool. See man pages of the
diff3
command for
more details.
Another important utility is
sdiff
that finds difference between two files and merges
these two files into a third file. The general format of
sdiff
is as follows.
sdiff –o outfile [options] file1 file2
The
sdiff
is useful when you want to interactively merge two files. This is the case
when two people have made changes to a source file and at some point you want to merge these
changes into a single file. The
sdiff
utility is interactive and it displays two files being com-
pared in side-by-side fashion. It stops on each difference with a % sign prompt. On this sign you
can press different characters to make a decision. Common responses on the % prompt are
shown in Table 7-2.
-c
Context output
-n
RCS style of output
-r
Compare directories recursively
-y
Use side-by-side format
Table7-2 Commands used on %
prompt of
sdiff
CommandDescription
L
Use the left side of the version
R
Use the right side of the version
e l
Edit and then use the left side
e r
Edit and use the right side
Q
Quit
Table7-1 Common options used with the
diff
command (Continued)
OptionDescription
Next Page >>
<< Previous Page
Back to the Table of Contents