.\" Copyright (c) 1987, 1990 The Regents of the University of California.
.\" %sccs.include.redist.man%
.\" @(#)cmp.1 6.3 (Berkeley) %G%
The cmp utility compares two files.
cmp writes no output if the files are the same; if they
differ, it writes to standard output the byte and line
number at which the first difference occurred.
lines are numbered beginning with one.
The following options are available:
Print the byte number (decimal) and the differing
bytes (octal) for each difference.
Print nothing for differing files; return exit
Nothing is guaranteed if both
The following operands are available:
A pathname of the first file to be compared.
the standard input is used.
A pathname of the second file to be compared.
The input files can be any file type.
Results of the comparison are written to standard output.
When no options are used, the format is:
"%s %s differ: char %d, line %d\en", <file1>,
<file2>, <byte number>, <line number>
option is used, the format is:
"%d %o %o\en", <byte number>, <differing byte>,
for each byte that differs. The first byte number is from
file1 while the second is from file2.
If file1 and file2 are identical for the entire length of
the shorter file, the following format is used, unless the
"cmp: EOF on %s\en", <name of shorter file>
No output is written to standard output when the
utility exits with one of the following values:
The files are different; this includes the case
where one file is identical to the first part of
In the latter case, if the -s option has
not been specified, cmp writes to standard error
that EOF was reached in the shorter file (before
any differences were found).
function is expected to be POSIX 1003.2 compatible.