Comparing files with cmp

Suppose you've been working on the dear liza file and you want to know how it differs from the dearhenry file. Using cmp, you can compare the two files as shown in Code Listing 6.13.

To compare files with cmp:

  • cmp dearliza dearhenry
    At the shell prompt, type cmp followed by both file names. As Code Listing 6.13 shows, these two files are not the same. If the files are identical, you'll find yourself back at the shell prompt with no comment from UNIX. If both files are identical until one of them ends—that is, say, the first 100 lines are the same, but one continues and the other ends—then you'll see an EOF (end of file) message, as in Code Listing 6.14.

Tip

You can find out other ways that files differ using diff, as ...

Get Unix: 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.