100 Useful Command-Line Utilities

by Oliver; 2014

57. diff, comm

diff prints out the differences between two files. It's the best way to find discrepancies between files you think are the same. If:
$ cat tmp1
a
a
b
c
$ cat tmp2
a
x
b
c
then diff catches that line 2 is different:
$ diff tmp1 tmp2
2c2
< a
---
> x
comm, for common, is similar to diff but I rarely have occasion to use it.

Note: If you're familiar with git, you know that the diff operation plays a central role in its version control system. Git has its own flavor of diff: git diff. For example, to see the difference between commit c295z17 and commit e5d6565:
$ git diff c295z17 e5d6565

<PREV   NEXT>