Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What is the difference between Context output format and Unicode output format when taking a diff?

diff -NBur dir1/ dir2/  
diff -NBcr dir1/ dir2/  
share|improve this question

1 Answer 1

up vote 3 down vote accepted

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?

share|improve this answer
    
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
    
@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
    
Thanks ,Alex :-) –  Sen Dec 14 '10 at 13:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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