进行比较时,复制上下文输出格式和统一上下文输出格式有什么区别?
diff -NBur dir1/ dir2/
diff -NBcr dir1/ dir2/
答案1
显然你误读了说明书。该-u
旗帜是为了统一上下文,不是 Unicode,-c
用于复制的上下文,而不是“上下文格式”:
-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.
找出差异的最直接方法是尝试一下:
$ 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
你明白有什么区别吗?