Cmp (Unix)

Uses your system voice; voice and rate in settings.

Snapshot

≈ 3 min read

Names in other languages

No names in other languages are held for this entry yet.

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

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.

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.

Use

Command line options include: Operands that are byte counts are decimal by default, 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.

Example

See also

Comparison of file comparison tools List of POSIX commands

References

External links

Comparing and Merging Files: Invoking cmp The section of the manual of GNU cmp in the diffutils free manual.

Text derived from https://en.wikipedia.org/w/index.php?oldid=1336327764 under CC BY-SA 4.0; modifications have been made.

Sources cited in this revision

5 named source(s) extracted from the cited revision. A source with no author is shown by its publication; nothing is invented.