When you only want to find out whether files are different, and you
don’t care what the differences are, you can use the summary output
format. In this format, instead of showing the differences between the
diff simply reports whether files differ. The
--brief (-q) option selects this output format.
This format is especially useful when comparing the contents of two
directories. It is also much faster than doing the normal line by line
diff can stop analyzing the files as soon as
it knows that there are any differences.
You can also get a brief indication of whether two files differ by using
cmp. For files that are identical,
cmp produces no
output. When the files differ, by default,
cmp outputs the byte
and line number where the first difference occurs, or reports that one
file is a prefix of the other. You can use
the -s, --quiet, or --silent option to
suppress that information, so that
produces no output and reports whether the files differ using only its
exit status (see Invoking cmp).
cmp cannot compare directories; it can only
compare two files.