Linux system uses CMP and COMM commands to compare two files

Source: Internet
Author: User

Cmp

CMP command: Compare any two types of files, and the results output to the standard output, the default file is the same output, different file output differences

Necessary parameters

-C Displays different information

-l list all the different information

-S error message does not prompt

Select parameters

-i< characters > specified number of characters

-V Display version information

--HELP Display Help information

"Return value of function"

0: The file is the same

1: The files are different

>1: Error occurred

Cases:

The code is as follows:

[Root@localhost www]# cmp test1.rb test.rb #比较二个文件的不同

TEST1.RB test.rb Differ:byte 1, line 1

[Root@localhost www]# cmp-l test1.rb test.rb #显示所有不同

1 160 162

2 165 145

3 164 161

4 163 165

5 40 151

6 42 162

7 150 145

8 145 40

9 153 42

10 153 155

11 153 171

12 42 163

13 12 161

Cmp:eof on TEST1.RB

Comm

Comm-Compare two sorted files on a line-by-row basis

Compare sorted files Left_file and Right_file line by row.

-1

Masks rows (or content) different from the right file in the left file (left_file)

-2

Mask the row (or content) in the right file (Right_file) that differs from the left file

-3

Mask the same line (or content) in two files

(The original is "not the same line", the suspect is wrong)

-L

The input data is considered to be sorted according to the current locale (the-l option should be given to sort).

--help

Display Help information, and then end

--version

Display version information, and then end

Cases:

The code is as follows:

[root@localhost www]# comm test.rb test1.rb #比较二个文件

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.