cmp

compare two files 

Command


SYNOPSIS

cmp [-blsx] file1 file2 [seek1[seek2]]


DESCRIPTION

cmp compares two files. If either file name is -, cmp reads the standard input for that file. By default, cmp begins the comparison with the first byte of each file. If you specify seek1 and/or seek2, cmp uses it as a byte offset into file1 or file2 (respectively), and comparison begins at that offset instead of at the beginning of the files. The comparison continues (one byte at a time) until a difference is found, at which point the comparison ends and cmp displays the byte and line number where the difference occurred. cmp numbers bytes and lines beginning with 1.

Options

-b 

compares single blocks at a time. Normally, cmp reads large buffers of data into memory for comparison.

-l 

causes the comparison and display to continue to the end. cmp displays the byte number (in decimal) and the differing bytes (in octal) for each difference found. cmp attempts no resynchronization.

-s 

suppresses output and returns a non-zero status if the files differ.

-x 

displays the differing bytes shown by the -l option in hex.


EXAMPLE

To determine if prog.exe and prog.com are instances of the same program (generated, for example, by exe2bin)

cmp prog.exe prog.com 512

DIAGNOSTICS

Possible exit status values are:

0 

The files were identical.

1 

The files were not identical.

2 

Failure due to invalid command line argument or option.

3 

Failure because of an error opening or reading an input file.

Messages

EOF on filename 

cmp reached end-of-file on the specified file before reaching end-of-file on the other file.


PORTABILITY

POSIX.2. x/OPEN Portability Guide 4.0. All UNIX systems. Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022. The -b and -x options and the seek pointers are extensions to the POSIX standard.


AVAILABILITY

PTC MKS Toolkit for Power Users
PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition
PTC Windchill Requirements and Validation


SEE ALSO

Commands:
comm, diff, uniq


PTC MKS Toolkit 10.4 Documentation Build 39.