In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to use the comm command in Linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
The common Linux command comm is used to compare two sequenced files. This instruction compares the differences between the two sorted files in a column and displays the results.
Comm compares two sorted files by line.
Summary comm [OPTION]... The main purpose of FILE1 FILE2 is to compare two sorted files by line.
When FILE1 or FILE2 is -, read standard input.
When there is no option, output three columns, the first column is unique to FILE1, the second column is unique to FILE2, and the third column is common to FILE1,FILE2.
Option-1 does not output the first column. -2 does not output the second column. -3 does not output the third column. -- check-order checks whether the input lines are sorted correctly, even if they are indeed sorted. -- nocheck-order does not check whether the input lines are sorted correctly. -- output-delimiter=STR uses STR as the delimiter between output columns instead of the default TAB. -- total adds an additional fourth column output summary. -z,-- zero-terminated sets the line Terminator to NUL (empty), not the newline character. -- help displays help information and exits. -- version displays version information and exits. A return value of 0 indicates success, while a non-zero value indicates failure.
Example text aaa.txt content
[root@localhost text] # cat aaa.txt aaa bbb ccc ddd eee 11122text bbb.txt content
[root@localhost text] # cat bbb.txt bbb ccc aaa hhh ttt jjj comparison result
[root@localhost text] # comm-- the first column of the nocheck-order aaa.txt bbb.txt aaa bbb ccc aaa ddd eee 111222 hhh ttt jjj output contains only the rows that appear in aaa.txt, the second column contains the rows that appear in bbb.txt, and the third column contains the same rows in aaa.txt and bbb.txt. The columns are separated by tabs (\ t).
Compare the sorted documents and sort the contents of the file first through sort:
[root@localhost ~] # sort aaa.txt > aaa1.txt [root@localhost ~] # sort bbb.txt > bbb1.txt comparison result:
[root@localhost ~] # comm aaa1.txt bbb1.txt 111222 aaa bbb ccc ddd eee hhh jjj ttt intersection prints the intersection of two files, you need to delete the first column and the second column:
[root@localhost text] # comm aaa.txt bbb.txt-1-2 bbb ccc difference can get the difference between aaa.txt and bbb.txt by deleting unwanted columns:
Difference sets of aaa.txt
[root@localhost text] # difference of comm aaa.txt bbb.txt-2-3aaadddeee111222bbb.txt
[root@localhost text] # comm aaa.txt bbb.txt-1-3aaahhhtttjjj Note this command is a command in the GNU coreutils package. For help, please see man-s 1 comm,info coreutils' comm invocation'.
This is the end of the article on "how to use comm commands in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.