User Tools

Site Tools


docs:diff:examples

This is an old revision of the document!


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

<HTML> <pre>

   1	--- <span style="color:red">a</span><span style="background-color:#ffd0d0">   </span><span style="color:red">2014-04-09 11:59:40.347723727 +0200</span>
   2	+++ <span style="color:green">d</span><span style="background-color:#d0ffd0">   </span><span style="color:green">2014-04-09 12:12:33.541634228 +0200</span>
   3	@@ <span style="color:red">-3,7</span> <span style="color:green">+3,7</span> @@
   4	 03
   5	 04
   6	 05
   7	<span style="color:red">-06</span>
   8	<span style="color:green">+06a</span>
   9	 07
  10	 08
  11	 09

</pre> </HTML>

<html><span style=“color:red”>a</span></html> file name 1
<html><span style=“color:green”>b</span></html> file name 2
<html><span style=“background-color:#ffd0d0”>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></html> a TAB char as separator
<html><span style=“background-color:#d0ffd0”>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></html> a TAB char as separator
<html><span style=“color:red”>2014-04-09 11:59:40.347723727 +0200</span></html> date of file 'a'
<html><span style=“color:green”>2014-04-09 12:12:33.541634228 +0200</span></html> date of file 'b'
<html>@@ <span style=“color:red”>-3,7</span> <span style=“color:green”>+3,7</span> @@</html> a 'hunk'
<html><span style=“color:red”>-3,7</span></html> range of the original file ('a') with '3' representing the starting line number and '7' the number of lines the hunk applies to
<html><span style=“color:green”>+3,7</span></html> range of the original file ('b') with '3' representing the starting line number and '7' the number of lines the hunk applies to
<html><span style=“color:red”>-06</span></html> removed line
<html><span style=“color:green”>+06a</span></html> added line

see also

docs/diff/examples.1441899071.txt.gz · Last modified: 2015/09/10 17:31 by 87.158.187.181