is another program for comparing files.
(There's also a GNU version on the CD-ROM.)
It's a lot simpler than
it tells you whether
the files are equivalent, and the byte offset at which the first
difference occurs. You don't get a detailed analysis of where the two
For this reason, cmp
is often faster,
particularly when you're comparing
files: it doesn't have to
generate a long report summarizing the differences.
If all you want
to know is whether two files are different, it's the right
tool for the job.
It's worth noting, though, that cmp
Some versions of diff
make some simple checks first, like
comparing file length. If two binary files have different lengths,
they are obviously different; some diff
tell you so without doing any further processing.
exit status (44.7
that shows what they found:
||The files were the same.
||The files differed.
||An error occurred.
Within a shell script, the exit status from diff
is often more important than their actual output.