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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.