COHERENT manpages

This page displays the COHERENT manpage for cmp [Compare bytes of two files].

List of available manpages
Index


cmp -- Command

Compare bytes of two files
cmp [-ls] file1 file2 [skip1 skip2]

The command  cmp compares two files  byte by byte for  equality.  file1 and
file2 name the  files to compare; the file name  `-' indicates the standard
input.

If cmp  finds two bytes  that differ, it  prints the number of  the byte at
which the discrepancy occurs, then exits.  If it encounters EOF on one file
but not on the other, it prints the message:

    EOF on filen

cmp recognizes the following command-line options:

-l Note each  differing byte by printing the positions  and octal values of
   the bytes of each file.

-s Print nothing, but return the exit status.

By default,  cmp begins  at byte  1 of each  file.  The  optional arguments
skip1 and  skip2 are integer values  that tell cmp to  skip that many bytes
for the  corresponding file before it begins  the comparison.  For example,
the command

    cmp FOO BAR 35 40

tells cmp to  skip the first 35 bytes of FOO  and the first 40 bytes of BAR
before it begins to compare them.

See Also

commands,
diff,
sh,
zcmp

Diagnostics

cmd returns zero for identical  files, one for non-identical files, and two
for errors, e.g., bad command or inaccessible file.