The cmp command compares files designated by the File1 and File2 parameters and writes the results to standard output. If you specify a - (minus sign) for either the File1 or File2 parameter, the cmp command reads standard input for that file. Only one file can be read from standard input. Under default conditions, the cmp command displays nothing if the files are the same. If they differ, the cmp command displays the byte and line number at which the first difference occurs. If the -l flag is specified and if one file is an initial subsequence of the other (that is, if the cmp command reads an end-of-file character in one file before finding any differences), the cmp command notes this. Normally, use the cmp command to compare non-text files and the diff command to compare text files.
This command returns the following
exit values:
cmp prog.o.bak prog.o
This compares prog.o.bak and prog.o. If the files are identical, then a message is not displayed. If the files differ, then the location of the first difference is displayed; for example:
prog.o.bak prog.o differ: char 4, line 1
If the message cmp: EOF on prog.o.bak is displayed, then the first part of prog.o is identical to prog.o.bak, but there is additional data in prog.o.
5 101 141
/usr/bin/cmp | Contains the cmp command. |
The comm command, diff command, ksh command.
Files Overview in AIX 5L Version 5.1 System User's Guide: Operating System and Devices.
Input and Output Redirection Overview. in AIX 5L Version 5.1 System User's Guide: Operating System and Devices.