recommended: More Linux file Lookup and comparison commands attention:Linux commands Daquan
A CMP command is used to compare two files for differences. When the two files that are compared to each other are exactly the same, the instruction does not display any information. If a discrepancy is found, the preset will indicate the number of characters and columns that are not in the first place. 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.
Grammar
CMP (options) (parameters)
Options
-C or--print-chars: In addition to the decimal loadline that indicate the difference, the number of characters;-i< characters of the character is displayed together with the number of > or--ignore-initial=< characters;: Specify a number;-L or-- VERBOSE: Mark out all the different places;-S or--quiet or--silent: Error messages are not displayed;-V or--version: Displays version information;--help: Online assistance.
Parameters
Table of Contents: Compare the differences of two files.
Instance
Using the CMP command to compare the file "Testfile" and the file "Testfile1" two files, enter the following command:
CMP testfile testfile1 #比较两个指定的文件
Before the above instruction is executed, use the Cat command to view the contents of the two specified files as follows:
Cat testfile #查看文件内容 absncn #显示文件 "testfile" Asldssja JSLKADJLS- cat Testfile1 # View file contents absncn #显示文件 "Testfile1" Asldssje JSLKADJLS 85
The CMP command is then executed, and the comparison results are returned, as follows:
CMP testfile testfile1 #比较两个文件 testfile testfile1 #有差异: 8th Byte, line 2nd
Note: In the comparison results, only the first comparison results can be displayed.
Linux cmp-compare two files for differences