4

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/  
10

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?

  • i admit the mistake i made in telling unified context format. But the man page of diif says -c as context output format. – Sen Dec 14 '10 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? – Sen Dec 14 '10 at 9:28
  • 2
    @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 Dec 14 '10 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.