Diff


 * For "diff files" in general, see Archiving. For Xerox DIFF, see XIFF.

diff is a family of formats associated with the traditional Unix  utility, especially the GNU implementation of it. It encodes the differences between two files. It is often used in the form of a "patch" file that can be used to convert one file to the other.

Diff is intended for use with text files whose lines are mostly short, such as source code.

Formats
The  utility can produce several different formats:

Normal diff
The default format, sometimes called "normal diff", contains just the differences, with no header or context.

Context diff
produces Context diff format. It has a header, and some contextual data that often makes it possible to patch files even after they have been modified.

It is characterized by lines with lots of asterisks: ***************

Note that the term "context diff" is sometimes used to mean "any diff format that features context" (which would include Unified diff, a different format).

Unified diff
Main article: Unified diff

produces Unified diff format. The idea is the same as with Context diff, but the format is more efficient and readable. It is characterized by lines that begin with "@@".

ed script
produces a script to be interpreted by the  text editor. It was used for patch files before the introduction of the  utility, but has long been obsolete for that purpose.

Software

 * GNU Diffutils: ,

Links

 * Diff utility
 * GNU Diffutils manual: Output Formats
 * Using diff and patch
 * The Ten Minute Guide to diff and patch