cmp (Unix)

cmp
Original authorsDennis Ritchie
(AT&T Bell Laboratories)
DevelopersVarious open-source and commercial developers
Initial releaseNovember 3, 1971 (1971-11-03)
Written inPlan 9: C
Operating systemUnix, Unix-like, Plan 9, Inferno, OS-9, IBM i
TypeCommand
Licensecoreutils: GPLv3+
Plan 9: MIT License

cmp is a shell command that compares two files of any type and reports differences. By default, it outputs nothing if the files match. If they differ, it reports the byte and line number of the first difference. The exit code can be used programmatically since it is 0 if the files match, 1 if the files differ or 2 if comparison fails (i.e. inaccessible or missing argument).

The command is available on Unix-like systems, OS-9, IBM i and Windows (via UnxUtils). The command first appeared in Version 1 Unix. It is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX.1 and the Single Unix Specification. The implementation in GNU coreutils was written by Torbjorn Granlund and David MacKenzie.