# 1行目、14桁目のデータが異なる。 $ cmp a.txt b.txt a.txt b.txt differ: char 14, line 1 # 14桁目のデータは8進数で(101:A)と(102:B)である。 # また b.txt の方が小さい(先にファイルの終了を検出) $ cmp -l a.txt b.txt 14 101 102 cmp: EOF on b.txt # ファイルが異なる時は1、同じときは0を返す $ cmp -s a.txt b.txt ; echo $? 1 $ cmp -s a.txt a.txt ; echo $? 0
$ comm a.txt b.txt This is File A # a.txt にだけある行 This is File B # b.txt にだけある行 same DATA # 両方にある行 End of file $ comm -3 a.txt b.txt This is File A This is File B End of file $ comm -23 a.txt b.txt This is File A End of file