Latest web development tutorials

Linux cmp Command

Linux command Daquan Linux command Daquan

Are Linux cmp command to compare two files differ.

When two files compared to each other exactly the same time, the directive does not display any information. If found to be different, the preset will mark the first character of the difference between the number of columns and number. If the file name or specify any given file name is "-", the cmp instruction reads data from standard input device.

grammar

cmp [-clsv][-i <字符数目>][--help][第一个文件][第二个文件]

Parameters:

  • -c or --print-chars except marked difference decimal character code at the outside, along with display the character corresponding to the character.
  • -i <number of characters> or --ignore-initial = <number of characters> specify a number.
  • -l or --verbose designate all the different places.
  • -s or --quiet or --silent does not display an error message.
  • -v or --version display version information.
  • --help online help.

Examples

To determine whether two files are identical, enter:

cmp prog.o.bak prog.o 

This comparison prog.o.bak and prog.o. If the files are identical message. If the file is different, a different location is the first display; for example:

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

If the message cmp: EOF on prog.o.bak, the first part of prog.o.bak prog.o the same, but there are other data in prog.o.

Linux command Daquan Linux command Daquan