Diff

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
(add more extensions)
(replace broken links with archived)
Line 41: Line 41:
 
* [[Wikipedia:Diff utility]]
 
* [[Wikipedia:Diff utility]]
 
* [http://www.gnu.org/software/diffutils/manual/html_node/Output-Formats.html GNU Diffutils manual: Output Formats]
 
* [http://www.gnu.org/software/diffutils/manual/html_node/Output-Formats.html GNU Diffutils manual: Output Formats]
* [https://linuxacademy.com/blog/2012/09/18/introduction-using-diff-and-patch/ Using diff and patch]
+
* [https://web.archive.org/web/20190905202025/https://linuxacademy.com/blog/linux/introduction-using-diff-and-patch/ Using diff and patch (archived)]
* [http://jungels.net/articles/diff-patch-ten-minutes.html The Ten Minute Guide to diff and patch]
+
* [https://web.archive.org/web/20151015015305/http://jungels.net/articles/diff-patch-ten-minutes.html The Ten Minute Guide to diff and patch (archived)]
  
 
== References ==
 
== References ==
 
<references/>
 
<references/>

Revision as of 23:53, 27 December 2023

File Format
Name diff
Ontology
Extension(s) .patch, .diff, .pch[1], .dif[2], .rej[3]

example of unified diff

example of unified diff

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

diff is a family of formats associated with the traditional Unix diff 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.

Contents

Formats

The diff 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

diff -c 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

diff -u 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

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

Software

Links

References

  1. https://file-extension.net/seeker/file_extension_pch
  2. https://file-extension.net/seeker/file_extension_dif
  3. https://file-extension.net/seeker/file_extension_rej
Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox