Programmers sometimes use a program called ‘diff’ to compare two files. While diff is a tool created by geeks, for geeks, there are only 4 rules you need to know in order to read the output from diff. Here is sample output from running diff to compare two files, which we’ll call File1 and File2. The geek might tell you (s)he ran “diff File1 File2”.
<pre>
0a1,4
This is an important notice! It should therefore be located at
11,14c14 < This paragraph contains < text that is outdated. < It will be deleted in the < near future. — 17c17 < check this dokument. On — check this document. On
</pre></code>
- Ignore all lines except those that begin with either "<" or ">".
- A line which begins with "<" is in File1 but not in File2.
- A line which begins with ">" is in File2 but not in File1.
- If you see a line which begins with "<" and it is followed by a similar line which begins with ">", then the line in File2 is a changed edition of the line from File1 (i.e. the line was deleted from the first file and added to the second file, with revisions).
</ol>
In the example above,
is in File2 but not File1This is an important notice! It should therefore be located at [blank line here]
is in File1 but not File2 There is a line in File1 which reads:This paragraph contains text that is outdated. It will be deleted in the near future.
and File2 corrects the spelling of "doKument" to "doCument", and the line in File2 ischeck this dokument. On
Piece of cake! Just remember the 4 rules:check this document. On
- Ignore all lines except those that begin with either "<" or ">".
- A line which begins with "<" is in File1 but not in File2.
- A line which begins with ">" is in File2 but not in File1.
- If you see a line which begins with "<" and it is followed by a similar line which begins with ">", then the line in File2 is a changed edition of the line from File1 (i.e. the line was deleted from the first file and added to the second file, with revisions). </ol> Some content adapted from http://en.wikipedia.org/wiki/Diff#Usage.