9

What is the difference between Copied context output format and Unified context output format when taking a diff?

diff -NBur dir1/ dir2/  
diff -NBcr dir1/ dir2/  

1 Answer 1

13

Apparently you've misread the manual. The -u flag is for unified context, not Unicode and -c is for copied context, not 'Context format':

-c -C NUM --context[=NUM] Output NUM (default 3) lines of copied context.

-u -U NUM --unified[=NUM] Output NUM (default 3) lines of unified context.

The most straightforward way to find out what is the difference, is to try it out:

$ cat >1
line
diff 
more
^D
$ cat >2
line 
ffid
more
^D
$ diff -c 1 2
*** 1   2010-12-14 09:08:48.019797000 +0200
--- 2   2010-12-14 09:08:56.029797001 +0200
***************
*** 1,3 ****
  line
! diff
  more
--- 1,3 ----
  line
! ffid
  more
$ diff -u 1 2
--- 1   2010-12-14 09:08:48.019797000 +0200
+++ 2   2010-12-14 09:08:56.029797001 +0200
@@ -1,3 +1,3 @@
 line
-diff
+ffid
 more

Do you get what's the difference?

3
  • i admit the mistake i made in telling unified context format. But the man page of diif says -c as context output format. Commented Dec 14, 2010 at 9:25
  • Do you get what's the difference? i could see only difference in the symbols used. In one it is * and in the other it is +. Does it imply something else? Commented Dec 14, 2010 at 9:28
  • 3
    @Sen: that, plus with -c you have two blocks of differing text, where ! marks the lines which differ, and with -u there is only one, where + and - before line denote versions of the differing line: minus when line in 1 is missing from 2, plus when line in 2 was added to 1. Is this clear enough now?
    – alex
    Commented Dec 14, 2010 at 13:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .