01.09.2014 Views

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CH07.fm Page 218 Monday, October 7, 2002 9:12 PM<br />

218 Chapter 7 • Miscellaneous Tools<br />

Table 7-1 Common options used with the diff comm<strong>and</strong> (Continued)<br />

Option<br />

Description<br />

-c Context output<br />

-n RCS style of output<br />

-r Compare directories recursively<br />

-y Use side-by-side format<br />

7.3.1 Other Forms of diff Utility<br />

<strong>The</strong>re are two other important forms of the diff utility. <strong>The</strong>se are diff3 <strong>and</strong> sdiff.<br />

<strong>The</strong> diff3 utility is used to compare three files <strong>and</strong> its general format is shown below.<br />

diff3 [options] mine older yours<br />

Suppose you <strong>and</strong> your colleague start working on a file simultaneously. <strong>The</strong> original file is<br />

the older file. Now you have your copy of the file (the mine file) <strong>and</strong> your colleague has his own<br />

copy of the file (the yours file). If you want to compare both of these modified copies of the file<br />

with the original older file, diff3 is a useful tool. See man pages of the diff3 comm<strong>and</strong> for<br />

more details.<br />

Another important utility is sdiff that finds difference between two files <strong>and</strong> merges<br />

these two files into a third file. <strong>The</strong> general format of sdiff is as follows.<br />

sdiff –o outfile [options] file1 file2<br />

<strong>The</strong> sdiff is useful when you want to interactively merge two files. This is the case<br />

when two people have made changes to a source file <strong>and</strong> at some point you want to merge these<br />

changes into a single file. <strong>The</strong> sdiff utility is interactive <strong>and</strong> it displays two files being compared<br />

in side-by-side fashion. It stops on each difference with a % sign prompt. On this sign you<br />

can press different characters to make a decision. Common responses on the % prompt are<br />

shown in Table 7-2.<br />

Table 7-2 Comm<strong>and</strong>s used on % prompt of sdiff<br />

Comm<strong>and</strong><br />

Description<br />

L<br />

R<br />

e l<br />

e r<br />

Q<br />

Use the left side of the version<br />

Use the right side of the version<br />

Edit <strong>and</strong> then use the left side<br />

Edit <strong>and</strong> use the right side<br />

Quit

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!