Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > C


HP-UX 11i Version 3: February 2007

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index


cmp — compare two files


cmp [-l] [-s] file1 file2 [skip1 [skip2]]


cmp compares two files (if file1 or file2 is -, the standard input is used). Under default options, cmp makes no comment if the files are the same; if they differ, it announces the byte and line number at which the difference occurred. If one file is an initial subsequence of the other, that fact is noted. skip1 and skip2 are initial byte offsets into file1 and file2, respectively; and maybe octal or decimal; the form of the number is determined by the environment variable LC_NUMERIC (in the C locale, a leading 0 denotes an octal number. See LANG on environ(5) and strtol(3C)).

cmp recognizes the following options:


Print the byte number (decimal) and the differing bytes (octal) for each difference (byte numbering begins at 1 rather than 0).


Print nothing for differing files; return codes only.


Environment Variables

LANG determines the language in which messages are displayed. If LANG is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG. If any internationalization variable contains an invalid setting, cmp behaves as if all internationalization variables are set to "C". See environ(5).

International Code Set Support

Single- and multi-byte character code sets are supported.


cmp returns the following exit values:


Files are identical.


Files are not identical.


Inaccessible or missing argument.

cmp prints the following warning if the comparison succeeds till the end of file of file1(file2) is reached.

cmp: EOF on file1(file2)


comm(1), diff(1).


cmp: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.