Linux cmp Command
The Linux cmp command is used to compare two files for differences.
When the two files being compared are exactly the same, the command displays nothing. If a difference is found, by default it indicates the character and line number of the first difference. If no filename is specified, or the given filename is "-", the cmp command reads data from standard input.
Syntax
cmp [-clsv][-i <字符数目>][--help][第一个文件][第二个文件]
Parameters:
- -c or --print-chars In addition to marking the decimal character code at the difference, also display the corresponding character.
- -i
or --ignore-initial= Specify a number. - -l or --verbose Mark all the differences.
- -s or --quiet or --silent Do not display error messages.
- -v or --version Display version information.
- --help Online help.
Example
To determine whether two files are identical, enter:
cmp prog.o.bak prog.o
This compares prog.o.bak and prog.o. If the files are identical, no message is displayed. If they differ, the position of the first difference 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 first part of prog.o is the same as prog.o.bak, but prog.o contains additional data.
Linux Command Reference