Linux cmp Command
The Linux cmp command is used to compare two files for differences.
When the two files being compared are identical, the command does not display any information. If differences are found, by default, it marks the first differing character and its line number. If no file names are specified or the given file name is "-", the cmp command will read data from the standard input device.
Syntax
cmp [-clsv][-i <number of characters>][--help][first file][second file]
Parameters:
-c or --print-chars: Displays the decimal code of the differing character along with the corresponding character.
-i<number of characters> or --ignore-initial=<number of characters>: Specifies a number of characters to ignore.
-l or --verbose: Marks all differing places.
-s or --quiet or --silent: Does not display error messages.
-v or --version: Displays version information.
--help: Online help.
Example
To determine if two files are identical, enter:
cmp prog.o.bak prog.o
This compares prog.o.bak and prog.o. If the files are the same, no message is displayed. If the files are different, the first differing position is shown; for example:
prog.o.bak prog.o differ: char 4, line 1
If the message "cmp: EOF on prog.o.bak" is displayed, the initial part of prog.o matches prog.o.bak, but there is additional data in prog.o.