快速顯示2個目錄dir1,dir2下所有不同文件名稱
diff -ruNaq dir1 dir2
diff -ruaq dir1 dir2(如果dir1和dir2中彼此都沒有對方文件,那麼將以only的形式human提示)
因爲需要往terminal輸出log,所以感覺會比bcompare慢,實際上用如下方法你就能知道diff有多快了
(當然diff -rNq和diff -rq效果和-ruNaq一樣)
diff -ruNaq dir1 dir2 > /dev/null
生成patch
diff -ruNa dir1 dir2 > test.patch
-----------------------------------------------------------------------------------
例如:
# ls test -R
test:
a b c
test/a:
aa
test/b:
bb
test/c:
# ls test1 -R
test1:
a b
test1/a:
aa
test1/b:
bb
# diff test test1
Common subdirectories: test/a and test1/a
Common subdirectories: test/b and test1/b
Only in test: c
# diff -r test test1
diff -r test/b/bb test1/b/bb
0a1
> 1
Only in test: c
# diff -rq test test1
Files test/b/bb and test1/b/bb differ
Only in test: c
# diff -rqN test test1
Files test/b/bb and test1/b/bb differ
# diff -rqNa test test1
Files test/b/bb and test1/b/bb differ
# diff -rqNau test test1
Files test/b/bb and test1/b/bb differ
-----------------------------------------------------------------------------------
-a 把所有文件看出文本形式,並對它們進行逐行比較,即使它們看起來不是文件文件
-b 忽略空格
-B 忽略空白行
-i 忽略大小寫
--brief 只報告兩個文件是否相同,不報告詳細的不同信息
-c 使用上下文輸出格式
-d 改變算法,使得diff命令可能找到一個更小的文件差異
-e 產生一個將文件1變成文件2的“ed script”
-r 比較目錄時遞歸比較子目錄
-b 支持Unix的兼容性
-n RCS格式
-N 在目錄比較中,如果一個文件只出現在第一個目錄中,那麼認爲它在另外一個目錄中也出現,並且爲空
-p 顯示不同的信息位於哪個C函數中
-P 在目錄比較中,如果一個文件只出現在第二個目錄中,那麼認定它在另外一個目錄中也出現,並且爲空
--paginate 通過pr輸出,並且標記頁數
-q 不報告差異,只說明兩者內容是否有差異
-s 當比較的兩個文件相同時報告信息
-t 輸出時,[tab]鍵按照空格鍵來輸出
-T 輸出時,[tab]鍵輸出,而非空格鍵
-u 使用統一的輸出格式
-y 輸出使用對比格式
選擇參數
-D<宏名字> 引入if-then-else輸出格式來預處理宏名稱
-s<文件> 比較文件時,從指定的文件進行比較
--from-file<文件> 同所有的操作數比較指定的文件,可以是目錄
--new-group-format=<模式> 用指定的模式,按照 if-then-else方式,輸出第二個文件中的一組行內容
--help 顯示幫助信息
--version 顯示版本信息