cmp (Unix)
| cmp | |
|---|---|
| Original authors | Dennis Ritchie (AT&T Bell Laboratories) |
| Developers | Various open-source and commercial developers |
| Initial release | November 3, 1971 |
| Written in | Plan 9: C |
| Operating system | Unix, Unix-like, Plan 9, Inferno, OS-9, IBM i |
| Type | Command |
| License | coreutils: 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.