The standard (old) output format will display the difference between the files without surrounding text with areas where the files differ.
For example: 1d0 <
(delete) means the apples needs to be removed from the 1st line of file1
, and 2a2 >
(append) means the apples needs to be added into file2
on the 2nd line, so both files can be matched.
Documentation available at info diff
explains it further more:
Showing Differences Without Context
The "normal" diff
output format shows each hunk of differences without any surrounding context. Sometimes such output is the clearest way to see how lines have changed, without the clutter of nearby unchanged lines (although you can get similar results with the context or unified formats by using 0 lines of context). However, this format is no longer widely used for sending out patches; for that purpose, the context format and the unified format are superior.
Normal format is the default for compatibility with older versions of diff
and the POSIX standard. Use the --normal
option to select this output format explicitly.
Detailed Description of Normal Format
The normal output format consists of one or more hunks of
differences; each hunk shows one area where the files differ. Normal
format hunks look like this:
CHANGE-COMMAND
< FROM-FILE-LINE
< FROM-FILE-LINE...
---
> TO-FILE-LINE
> TO-FILE-LINE...
There are three types of change commands. Each consists of a line
number or comma-separated range of lines in the first file, a single
character indicating the kind of change to make, and a line number or
comma-separated range of lines in the second file. All line numbers
are the original line numbers in each file. The types of change
commands are:
LaR
Add the lines in range R of the second file after line L of the
first file. For example, 8a12,15
means append lines 12-15 of
file 2 after line 8 of file 1; or, if changing file 2 into file 1,
delete lines 12-15 of file 2.
FcT
Replace the lines in range F of the first file with lines in range
T of the second file. This is like a combined add and delete, but
more compact. For example, 5,7c8,10
means change lines 5-7 of
file 1 to read as lines 8-10 of file 2; or, if changing file 2 into
file 1, change lines 8-10 of file 2 to read as lines 5-7 of file 1.
RdL
Delete the lines in range R from the first file; line L is where
they would have appeared in the second file had they not been
deleted. For example, 5,7d3
means delete lines 5-7 of file 1;
or, if changing file 2 into file 1, append lines 5-7 of file 1
after line 3 of file 2.
See also:
So to see the oranges, you would have to diff it either by side by side or by using unified context.
In example:
$ diff -y file1 file2
apples <
oranges oranges
> apples
$ diff -u file1 file2
@@ -1,2 +1,2 @@
-apples
oranges
+apples
oranges
is the largest common part between the two files, so what you obtain is the shortest way to express the differences between the two. – Stéphane Chazelas Jul 25 '14 at 10:30diff -u file1 file2
instead. That's called "unified diff" format. The original diff format was meant to be very compact, but unified diffs are meant to be much more readable. – godlygeek Jul 25 '14 at 11:43diff -y file1 file2
– user80551 Jul 25 '14 at 12:44