English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux cmp command

Linux Command大全

The Linux cmp command is used to compare whether two files have differences.

If the two files to be compared are exactly the same, this command will not display any information. If there are differences, the default is to indicate the character and line number of the first difference. If no file name is specified or the given file name is "-If the input is 'cmp [', 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 - In addition to displaying the decimal codes of the marked difference places, display the corresponding characters of the characters.
  • -i<number of characters> or--ignore-initial=<number of characters> - Specify a number.
  • -l or--verbose - Indicate all differences.
  • -s or--quiet or--silent - Do not display error information.
  • -v or--version - Display version information.
  • --help - Online Help.

Online Examples

To determine whether two files are the same, please 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 different position is displayed; for example:

prog.o.bak prog.o differ: char 4, line 1 

If the message 'cmp: EOF on prog.o.bak' is displayed, it means that the first part of prog.o is the same as prog.o.bak, but there are other data in prog.o.

Linux Command大全