Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux cmp Command

Linux cmp Command

Linux Command Reference Linux Command Reference

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:

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 Linux Command Reference