UNIX in a Nutshell: System V Edition

UNIX in a Nutshell: System V EditionSearch this book
Previous: Reference: clearChapter 2
UNIX Commands
Next: Reference: cof2elf
 

cmp

cmp [options] file1 file2

Compare file1 with file2. Use standard input if file1 is -. See also comm and diff. The exit codes are as follows:

0 Files are identical. 1 Files are different. 2 Files are inaccessible.

Options

-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.

Example

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

cmp -s old new && echo 'no changes'


Previous: Reference: clearUNIX in a Nutshell: System V EditionNext: Reference: cof2elf
Reference: clearBook IndexReference: cof2elf

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System