The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


cmp - compare two files


cmp [-l] [-s] file1 file2 [skip1 [skip2]]


cmp compares two files, byte-by-byte. The result of the comparison is always given by the exit status, and may be summarized on the standard output according to the options given on the command line.

If the two compared files are identical, cmp will exit with a zero exit status. If the compared files are not identical, cmp will exit with a status of 1.

If no options are given, cmp will return (on the standard output), the byte number and line number where the first difference is encountered.

If one file is an initial subsequence of the other, a message will also be returned on the standard error indicating that EOF was reached in the shorter of the two file.

skip1 and skip2 are optional byte offsets into file1 and file2, respectively, that determine where the file comparison will begin. Offsets may be given in decimal, octal, or hexadecimal form. Indicate octal notation with a leading '0', and hexadecimal notation with a leading '0x'.

file1 or file2 may be given as '-', which reads from standard input.



silent execution; indicate results only by exit status, suppressing all output and warnings.


list differences; return the byte number and the differing byte values for each difference between the two files. The byte number is given in decimal, and the byte values are given in octal.


show the documentation


No environment variables affect the execution of cmp.


No known bugs.


D Roland Walker <>.


This program is copyright (c) D Roland Walker 1999.

This program is free and open software. You may use, modify, distribute, and sell this program (and any modified variants) in any way you wish, provided you do not restrict others from doing the same.