diff(1) examples

files used

file a:

a
01
02
03
04
05
06
07
08
09
10

file b (“06” is missing):

b
01
02
03
04
05
07
08
09
10

file c (“06a” inserted):

c
01
02
03
04
05
06
06a
07
08
09
10

file d (“06a” replaces “06”):

d
01
02
03
04
05
06a
07
08
09
10

one deleted line

diff a b

6d5
< 06

diff -u a b

--- a   2014-04-09 11:59:40.347723727 +0200
+++ b   2014-04-09 11:59:51.651574650 +0200
@@ -3,7 +3,6 @@
 03
 04
 05
-06
 07
 08
 09

diff -e a b

6d

one additional line

diff a c

6d7
> 06a

diff -u a c

--- a   2014-04-09 11:59:40.347723727 +0200
+++ c   2014-04-09 12:08:41.088672486 +0200
@@ -4,6 +4,7 @@
 04
 05
 06
+06a
 07
 08
 09

diff -e a c

6a
06a
.

one line changed

diff a d

6c6
< 06
---
> 06a

diff -u a d

--- a   2014-04-09 11:59:40.347723727 +0200
+++ d   2014-04-09 12:12:33.541634228 +0200
@@ -3,7 +3,7 @@
 03
 04
 05
-06
+06a
 07
 08
 09

diff -e a d

6c
06a
.

output of "diff -u" explained

     1	--- a   2014-04-09 11:59:40.347723727 +0200
     2	+++ d   2014-04-09 12:12:33.541634228 +0200
     3	@@ -3,7 +3,7 @@
     4	 03
     5	 04
     6	 05
     7	-06
     8	+06a
     9	 07
    10	 08
    11	 09
a file name 1
b file name 2
       a TAB char as separator
       a TAB char as separator
2014-04-09 11:59:40.347723727 +0200 date of file 'a'
2014-04-09 12:12:33.541634228 +0200 date of file 'b'
@@ -3,7 +3,7 @@ a 'hunk'
-3,7 range of the original file ('a') with '3' representing the starting line number and '7' the number of lines the hunk applies to
+3,7 range of the original file ('b') with '3' representing the starting line number and '7' the number of lines the hunk applies to
-06 removed line
+06a added line

see also

docs/diff/examples.txt · Last modified: 2015/09/15 05:14 by 91.89.129.106
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki