Linux – the difference between Copied context output format and Unified context output format while taking diff

diff()linux

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/  

Best Answer

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?

Related Question