Skip to Content
Mac OS X in a Nutshell
book

Mac OS X in a Nutshell

by Jason McIntosh, Chuck Toporek, Chris Stone
January 2003
Intermediate to advanced
832 pages
32h 40m
English
O'Reilly Media, Inc.
Content preview from Mac OS X in a Nutshell

Name

cmp

Synopsis

cmp [options] file 
                     file2 [skip1 [skip2]]

Compares file1 with file2. Use standard input if file1 or file2 is -. To begin the comparison from byte offsets other than at the beginning of the files, use the optional arguments skip1 and skip2, which specify the byte offsets from the beginning of each file. By default, the value is decimal. To use hexadecimal or octal values, precede them with a leading 0x or 0, respectively. See also comm and diff. The exit codes are as follows:

0

Files are identical.

1

Files are different.

2

Files are inaccessible.

Options

-c, --print-chars

Print differing bytes as characters.

-i N, --ignore-initial= N

Ignore differences in the first N bytes of input.

-l

For each difference, print the byte number in decimal and the differing bytes in octal.

-s

Work silently; print nothing, but return exit codes.

-v, --version

Output version info.

Example

Print a message if two files are the same (exit code is 0):

                     cmp -s old new && echo 'no changes'
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mac OS X Internals: A Systems Approach

Mac OS X Internals: A Systems Approach

Amit Singh
C++ In a Nutshell

C++ In a Nutshell

Ray Lischner
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar
Optimized C++

Optimized C++

Kurt Guntheroth

Publisher Resources

ISBN: 0596003706Supplemental ContentCatalog PageErrata