Comparing Files

UNIX uses simple text files in a variety of important roles, including system configuration tables, C program source code, HTML Web pages, and user data. Because text files have so many important uses under UNIX, several different UNIX utilities enable you to compare text files and see their differences. To compare binary, non-text files, other commands can be used.

Showing Differences Between Two Files

To show the differences between two text files, use this command:

diff file1 file2

287c287 in diff Output

For the beginner, remember no news is good news. If diff shows no output, the files are identical. Any diff output means the files are different. The more output, the more lines that are different. In the example, you see ...

Get Practical UNIX 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.