Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the comm command of Linux

Shulou Source: shulou.com Published: 2022-06-01 15:41:15 10月04日 Update

Most people do not understand the knowledge points of this article "Linux's comm command how to use", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "Linux comm command how to use" article.

Prepare the files 1.txt and 2.txt

[h_chenliling@vm6-sj1-pro-had-32-107] $cat 1.txtabcdef1234567 [h _ chenliling@vm6-sj1-pro-had-32-107] $cat 2.txtdefghi1234567 [h _ chenliling@vm6-sj1-pro-had-32-107] $comm 1.txt 2.txtabc defgh i12345678910

The first column contains only the rows that appear in 1.txt, the second column contains the rows that appear in 2.txt, and the third column contains the same rows in 1.txt and 2.txt. Each column is delimited by a tab (\ t).

Intersection

Delete columns 1 and 2

[h_chenliling@vm6-sj1-pro-had-32-107] $comm 1.txt 2.txt-1-2def1234 difference set

The difference of 1.txt exists in 1.txt, but not in 2.txt. That is, delete columns 2 and 3.

[h_chenliling@vm6-sj1-pro-had-32-10710] $comm 1.txt 2.txt-2-3abc1234 difference

For different lines of two files, delete column 3 and merge column 1 and column 2

[h_chenliling@vm6-sj1-pro-had-32-10710] $comm 1.txt 2.txt-3 | sed's / ^\ t//'abcghi is about the article "how to use Linux's comm commands". I believe you all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about it, please follow the industry information channel.

Tags: Content commands same difference files articles knowledge articles two that is intersection values tabs most delimiters that is more steps knowledge points industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi macOS NVidia Linux Shulou Technology