cmp - Compare two files
Synopsis
cmp [-l | -s] [-t] file1 file2
[skip1 [skip2]]
Description
You can use cmp to compare two files. By
default, a byte for byte binary comparison is done. If no
differences are found, no output is written. If no option flags are
specified, cmp writes a message with the byte and
line number of the first difference and exits with an error. Bytes
and lines are numbered beginning with 1.
Options
- -l
- (Lower case ell) Write the byte number in decimal and the
differing bytes in octal for all differences.
- -s
- Silent mode where no output is written for differing files;
only the exit status is set.
- -t
- Text mode where the files are opened in text mode and
translated to the CCSID of the job before comparing byte for
byte.
Operands
The file1 and file2 operands are the two files
to be compared byte for byte. The optional skip1 and
skip2 are the number of bytes to skip from the beginning of
each file, respectively, before the comparison begins.
Environment Variables
cmp is affected by the following environment
variables:
- QIBM_CMP_FILE_SIZE
- Controls the maximum file size in bytes that cmp reads
into an internal buffer for better performance. For files larger than the
maximum size, cmp reads the files one byte at a time.
Exit Status
- 0 when the files are identical
- 1 when the files are different
- >1 when an error occurred
Related information
Examples
- Find the exact position where two files differ. It is better to
place the reference or good file first and then the changed or new
file second.
cmp myApplet.java.old myApplet.java.new