ArticleDirectory
- Parameters
- Option
- Example
- Tips
Compare two files
CMP [Options]File1 file2
CMP is used to compare two files in bytes. If the two files are the same, CMP does not display any content. Otherwise, CMP displays the number of bytes and row numbers corresponding to a different place.
Parameters
File1 AndFile2YesCMPThe path names of the two files to be compared.File2,CMPUse standard input instead.
Option
-B displays more information about the first byte, including the file name, number of bytes, row number, octal number, and ASCII value.
-L does not stop the comparison of the first different bytes, but continues to compare the two files and display the specific information.
-S disables output from CMP and is only used to exit (running)
Example CMP
$CMPA ba B is different:8Byte, number1Line
Direct comparison
CMP-B
$CMP-B A ba B is different:1Row, number8Byte:12^ J150H
Compare the details of the first byte
CMP-l
$ CMP - L A B 8 12 150 9 61 12 10 62 61 11 63 62 12 64 63 13 65 64 14 66 65 15 67 66 16 12 67 CMP : A ended
Compare all different bytes
Tips
CMP is not intuitive. In most cases, better diff is used for comparison. If you don't understand it, just skip it.