man Pages(1): User Commands
この本のみを検索
PDF 文書ファイルをダウンロードする

NAME

cmp - compare two files

SYNOPSIS

cmp [ -l ] [ -s ] filename1 filename2 [ skip1 ] [ skip2 ]

AVAILABILITY

SUNWcsu

DESCRIPTION

The two files are compared. (If filename1 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 numbers at which the first difference occurred. If one file is an initial subsequence of the other, that fact is noted. skip1 and skip2 are initial byte offsets into filename1 and filename2 respectively, and may be either octal or decimal; a leading 0 denotes octal.

OPTIONS

-l
Print the byte number (decimal) and the differing bytes (octal) for each difference.
-s
Print nothing for differing files; return exit codes only.

EXAMPLE

The following example:
example% cmp file1 file2 0 1024
does a byte for byte comparison of file1 and file2. It skips the first 1024 bytes in file2 before starting the comparison.

ENVIRONMENT

If any of the LC_ *variables ( LC_CTYPE, LC_MESSAGES, LC_TIME, LC_COLLATE, LC_NUMERIC, and LC_MONETARY ) (see environ(5)) are not set in the environment, the operational behavior of cmp for each corresponding locale category is determined by the value of the LANG environment variable. If LC_ALL is set, its contents are used to override both the LANG and the other LC_ *variables. If none of the above variables is set in the environment, the "C" (U.S. style) locale determines how cmp behaves.
LC_CTYPE
Determines how cmp handles characters. When LC_CTYPE is set to a valid value, cmp can display and handle text and filenames containing valid characters for that locale. cmp can display and handle Extended Unix Code (EUC) characters where any individual character can be 1, 2, or 3 bytes wide. cmp can also handle EUC characters of 1, 2, or more column widths. In the "C" locale, only characters from ISO 8859-1 are valid.
LC_MESSAGES
Determines how diagnostic and informative messages are presented. This includes the language and style of the messages, and the correct form of affirmative and negative responses. In the "C" locale, the messages are presented in the default form found in the program itself (in most cases, U.S. English).

SEE ALSO

comm(1), diff(1), environ(5)

DIAGNOSTICS

Exit code 0 is returned for identical files, 1 for different files, and 2 for an inaccessible or missing argument.