Skip to Content
Linux in a Nutshell, 6th Edition
book

Linux in a Nutshell, 6th Edition

by Ellen Siever, Stephen Figgins, Robert Love, Arnold Robbins
September 2009
Beginner
942 pages
85h 34m
English
O'Reilly Media, Inc.
Content preview from Linux in a Nutshell, 6th Edition

Name

cmp

Synopsis

cmp [options] file1 file2 [skip1 [skip2]]

Compare file1 with file2. Use standard input if file1 is - or missing. This command is normally used for comparing binary files, although files can be of any type. (See also diff.) skip1 and skip2 are optional offsets in the files at which the comparison is to start.

Options

-i num, --ignore-initial=num

Ignore the first num bytes of input. num can be given as num1:num2 to skip a different number of bytes in file1 and file2.

-l, --verbose

Print offsets and codes of all differing bytes.

-s, --quiet, --silent

Work silently; print nothing, return an exit code:

0

Files are identical.

1

Files are different.

2

Files are inaccessible.

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

Unix in a Nutshell, 4th Edition

Unix in a Nutshell, 4th Edition

Arnold Robbins
Linux Under the Hood

Linux Under the Hood

Sander van Vugt
Linux Kernel in a Nutshell

Linux Kernel in a Nutshell

Greg Kroah-Hartman

Publisher Resources

ISBN: 9780596806088Errata Page