Cmp (Unix)

In computing,   is a command-line utility on Unix and Unix-like operating systems that compares two files of any type and writes the results to the standard output. By default,  is silent if the files are the same; if they differ, the byte and line number at which the first difference occurred is reported. The command is also available in the OS-9 shell.

History
cmp 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. It first appeared in Version 1 Unix. The version of  bundled in GNU coreutils was written by Torbjorn Granlund and David MacKenzie. The command is available as a separate package for Microsoft Windows as part of the UnxUtils collection of native Win32 ports of common GNU Unix-like utilities. The cmp command has also been ported to the IBM i operating system.

Switches
may be qualified by the use of command-line switches. The switches supported by notable implementations of  are:

Operands that are byte counts are normally decimal, but may be preceded by ' ' for octal and ' ' for hexadecimal.

A byte count can be followed by a suffix to specify a multiple of that count; in this case an omitted integer is understood to be 1. A bare size letter, or one followed by ' ', specifies a multiple using powers of 1024. A size letter followed by ' ' specifies powers of 1000 instead. For example, ' ' and ' ' are equivalent to ' ', whereas ' ' is equivalent to ' '. This notation is upward compatible with the SI prefixes for decimal multiples and with the IEC 60027-2 prefixes for binary multiples.

Return values

 * 0 – files are identical
 * 1 – files differ
 * 2 – inaccessible or missing argument