Linux cmp-compare two files for differences

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.