Finding Differences in Files with diff

In addition to using cmp to find out how files differ, you can also use diff. This command tells you specifically where two files differ, not just that they differ and at which point the differences start (see Code Listing 6.15).

Code Listing 6.15. diff tells you all you ever wanted to know about the differences between two files but not in an easily readable manner.
[ejr@hobbes manipulate]$ diff dearlizadearhenry
2,3c2,3
< Dear Liza,
< There's a hole in my bucket, dear Liza,
  → dear Liza, dear Liza.
> Dear Henry,
> Please fix it dear Henry, dear Henry,
  → dear 'Henry.
5,6c5,6
< Henry
<
> Liza
> PS, you forgot your toolbox last time.
[ejr@hobbes manipulate]$

To find differences with diff:

  • diff dearliza ...

Get Unix Third Edition: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.