Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Diff
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Usage == The <code>diff</code> command is invoked from the command line, passing it the names of two files: <code>diff ''original'' ''new''</code>. The output of the command represents the changes required to transform the ''original'' file into the ''new'' file. If ''original'' and ''new'' are directories, then {{Mono|diff}} will be run on each file that exists in both directories. An option, <code>-r</code>, 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'': {{Col-begin}} {{Col-break|width=33%}} ''original'': <syntaxhighlight lang="text" line> This part of the document has stayed the same from version to version. It shouldn't be shown if it doesn't change. Otherwise, that would not be helping to compress the size of the changes. This paragraph contains text that is outdated. It will be deleted in the near future. It is important to spell check this dokument. On the other hand, a misspelled word isn't the end of the world. Nothing in the rest of this paragraph needs to be changed. Things can be added after it. </syntaxhighlight> {{col-break}} ''new'': <syntaxhighlight lang="text" line> This is an important notice! It should therefore be located at the beginning of this document! This part of the document has stayed the same from version to version. It shouldn't be shown if it doesn't change. Otherwise, that would not be helping to compress the size of the changes. It is important to spell check this document. On the other hand, a misspelled word isn't the end of the world. Nothing in the rest of this paragraph needs to be changed. Things can be added after it. This paragraph contains important new additions to this document. </syntaxhighlight> {{col-break|width=33%}} The command '''<code>diff original new</code>''' produces the following ''normal diff output'': {{pre| 0a1,6 {{font color|darkgreen|> This is an important > notice! It should > therefore be located at > the beginning of this > document! >}} 11,15d16 {{font color|darkred|< This paragraph contains < text that is outdated. < It will be deleted in the < near future. <}} 17c18 {{font color|darkred|< check this dokument. On}} --- {{font color|darkgreen|> check this document. On}} 24a26,29 {{font color|darkgreen|> > This paragraph contains > important new additions > to this document.}}}} '''Note''': ''Here, the diff output is shown with colors to make it easier to read. The diff utility does not produce colored output; its output is [[plain text]]. However, many tools can show the output with colors by using [[syntax highlighting]].'' {{col-end}} In this traditional output format, '''<samp>a</samp>''' stands for ''added'', '''<samp>d</samp>''' for ''deleted'' and '''<samp>c</samp>''' for ''changed''. Line numbers of the original file appear before <samp>a</samp>/<samp>d</samp>/<samp>c</samp> and those of the new file appear after. The [[Less-than sign|less-than]] and [[Greater-than sign|greater-than]] signs (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.<ref>{{cite book|title=Comparing and Merging Files with GNU Diff and Patch|url=https://www.gnu.org/software/diffutils/manual/|author1=David MacKenzie|author2=Paul Eggert|author3=Richard Stallman|isbn=978-0-9541617-5-0|publisher=Network Theory|year=1997|location=Bristol|access-date=2015-03-17|archive-date=2015-03-31|archive-url=https://web.archive.org/web/20150331031946/http://www.gnu.org/software/diffutils/manual/|url-status=live}}</ref> However, some diff tools highlight moved lines.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Diff
(section)
Add topic