CMP (Compare) command
Command function: Compare the differences between two files
Command usage: CMP [-clsv][-i < number of characters >][–help][first file] [second file]
When the two files that are compared to each other are identical, the instruction does not display any information;
If found to be different, the preset will indicate the first difference in the character and column number;
If you do not specify any file name or the given file name is "-", the CMP instruction will read the data from the standard input device.
Command parameters:
- -C or –print-chars displays the corresponding character of the character in addition to the decimal loadline that indicates the difference.
- -i< number of characters > or –ignore-initial=< characters > Specify a number.
- The-L or –verbose mark all the different places.
- -S or –quiet or –silent do not display an error message.
- -V or –version displays version information.
- Help online Help.
Example:
First prepare two files file1 and File2,
1. Compare File1 and File2:
Without parameters, the CMP instruction compares the first two file differences and outputs the first few bytes, the 1th row in the example, and the 5th byte in a different order.
2. Use the-c parameter to display the differential characters
3. Use the-l parameter to compare two files all different places
The first column is the byte position, and the 2nd, 3 columns are octal bytes
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
"Linux command-File management class" CMP command