Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the differences between using cmp and comm commands in Linux systems

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "what are the differences between using cmp and comm commands in Linux systems". In daily operation, I believe that many people have doubts about the differences between cmp and comm commands in Linux systems. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the questions of "what are the differences between cmp and comm commands in Linux systems?" Next, please follow the editor to study!

Cmp

Cmp command: compare any two types of files, and output the results to standard output. The same default file is not output, but 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 specify the number of characters

-v displays version information

-- help displays help information

[return value of function]

0: the file is the same

1: the files are different.

> 1: an error occurred

Example:

The code is as follows:

[root@localhost www] # cmp test1.rb test.rb # compare the differences between the two files

Test1.rb test.rb differ: byte 1, line 1

[root@localhost www] # cmp-l test1.rb test.rb # shows all the differences

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 line by line

Compare the sorted files LEFT_FILE and RIGHT_FILE line by line.

-1

Mask lines (or contents) in the file on the left (LEFT_FILE) that are different from the file on the right

-2

Mask lines (or contents) in the right file (RIGHT_FILE) that are different from the left file

-3

Mask the same line (or content) in both files

(translation note: the original text is "different lines", suspected to be incorrect)

-l

It is considered that the input data is sorted according to the current locale (the-l option should be provided for sort).

-- help

Display help information and then end

-- version

Display version information, and then end

Example:

The code is as follows:

[root@localhost www] # comm test.rb test1.rb # compare two files

At this point, the study on "what is the difference between using cmp and comm commands in Linux systems" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report