Diff - Usage

Usage

It is invoked from the command line with the names of two files: diff original new. The output of the command represents the changes required to make the original file become the new file.

If original and new are directories, then diff will be run on each file that exists in both directories. An option, -r, will recursively descend any matching subdirectories to compare files between directories.

Any of the examples in the article use the following two files, original and new:

original:

1 This part of the 2 document has stayed the 3 same from version to 4 version. It shouldn't 5 be shown if it doesn't 6 change. Otherwise, that 7 would not be helping to 8 compress the size of the 9 changes. 10 11 This paragraph contains 12 text that is outdated. 13 It will be deleted in the 14 near future. 15 16 It is important to spell 17 check this dokument. On 18 the other hand, a 19 misspelled word isn't 20 the end of the world. 21 Nothing in the rest of 22 this paragraph needs to 23 be changed. Things can 24 be added after it.

new:

1 This is an important 2 notice! It should 3 therefore be located at 4 the beginning of this 5 document! 6 7 This part of the 8 document has stayed the 9 same from version to 10 version. It shouldn't 11 be shown if it doesn't 12 change. Otherwise, that 13 would not be helping to 14 compress anything. 15 16 It is important to spell 17 check this document. On 18 the other hand, a 19 misspelled word isn't 20 the end of the world. 21 Nothing in the rest of 22 this paragraph needs to 23 be changed. Things can 24 be added after it. 25 26 This paragraph contains 27 important new additions 28 to this document.

The command diff original new produces the following normal diff output:

0a1,6 > This is an important > notice! It should > therefore be located at > the beginning of this > document! > 8,14c14 < compress the size of the < changes. < < This paragraph contains < text that is outdated. < It will be deleted in the < near future. --- > compress anything. 17c17 < check this dokument. On --- > check this document. On 24a25,28 > > This paragraph contains > important new additions > to this document.

In this traditional output format, a stands for added, d for deleted and c for changed. Line numbers of the original file appear before a/d/c and those of the modified file appear after. Angle brackets (at the beginning of lines that are added, deleted or changed) indicate which file the lines appear in. Addition lines are added to the original file to appear in the new file. Deletion lines are deleted from the original file to be missing in the new file.

By default, lines common to both files are not shown. Lines that have moved are shown as added at their new location and as deleted from their old location. However, some diff tools highlight moved lines.

Read more about this topic:  Diff

Famous quotes containing the word usage:

    Pythagoras, Locke, Socrates—but pages
    Might be filled up, as vainly as before,
    With the sad usage of all sorts of sages,
    Who in his life-time, each was deemed a bore!
    The loftiest minds outrun their tardy ages.
    George Gordon Noel Byron (1788–1824)

    ...Often the accurate answer to a usage question begins, “It depends.” And what it depends on most often is where you are, who you are, who your listeners or readers are, and what your purpose in speaking or writing is.
    Kenneth G. Wilson (b. 1923)

    I am using it [the word ‘perceive’] here in such a way that to say of an object that it is perceived does not entail saying that it exists in any sense at all. And this is a perfectly correct and familiar usage of the word.
    —A.J. (Alfred Jules)