Diff
diff 報告兩個文件不同,儘管它們是相同的!
我有兩個看起來與我相同的文件(包括尾隨空格和換行符),但 diff 仍然表示它們不同。即使我進行
diff -y
並排比較,線條看起來也完全相同。diff 的輸出是整個 2 個文件。知道是什麼原因造成的嗎?
奇怪..你能試試
cmp
嗎?您可能也想使用 ’-b
’ 選項。cmp 手冊頁- 逐字節比較兩個文件。
這是 Unix/Linux 的優點之一 .. 這麼多工具 :)
嘗試:
diff file1 file2 | cat -t
該
-t
選項將導致cat
清楚地顯示任何特殊字元 - 例如。^M
對於 CR,^I
對於選項卡。從手冊頁(OS X):
-t Display non-printing characters (see the -v option), and display tab characters as `^I'. -v Display non-printing characters so they are visible. Control characters print as `^X' for control-X; the delete character (octal 0177) prints as `^?'. Non-ASCII characters (with the high bit set) are printed as `M-' (for meta) followed by the character for the low 7 bits.