Top Qs
Timeline
Chat
Perspective

Cmp (Unix)

File comparison command From Wikipedia, the free encyclopedia

Remove ads

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).

Quick facts Original author(s), Developer(s) ...

The command is available on Unix-like systems, OS-9, IBM i and Windows (via UnxUtils).[1][2][3] The command first appeared in Version 1 Unix.[4] 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.[5] The implementation in GNU coreutils was written by Torbjorn Granlund and David MacKenzie.[6]

Remove ads

Use

Summarize
Perspective

Command line options include:

More information Option, Description ...

Operands that are byte counts are decimal by default, but may be preceded by '0' for octal and '0x' 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 'iB', specifies a multiple using powers of 1024. A size letter followed by 'B' specifies powers of 1000 instead. For example, '-n 4M' and '-n 4MiB' are equivalent to '-n 4194304', whereas '-n 4MB' is equivalent to '-n 4000000'. This notation is upward compatible with the SI prefixes[7] for decimal multiples and with the IEC 60027-2 prefixes for binary multiples.[8]

Remove ads

Example

Thumb
Example use to report different bytes between text files

See also

References

Loading related searches...

Wikiwand - on

Seamless Wikipedia browsing. On steroids.

Remove ads