Simple Linux Command Line notes: comm

Source: Internet
Author: User
ArticleDirectory
    • Parameters
    • Option
    • Note:
    • Example

Compare sorted files

Comm [Options]File1 file2

 

Comm compares two sorted files row by row. The display result includes three columns:

Column 1st is a row found only in file1, Column 2nd is a row found only in file2, and column 3rd is a public row of two files.

 

Parameters

ParametersFile1AndFile2IsCommThe path name of the file to be compared. Use a hyphen(-)To replaceFile1OrFile2,CommReads the input information from the standard input.

 

Option

-1: The 1st column is not displayed (that is, only the rows found in file1 are not displayed)

-2: The 2nd column is not displayed (that is, only the rows found in file2 are not displayed)

-3: do not display the 3rd columns (that is, do not display the rows found in both files)

 

Note:

If files are not sorted, comm cannot work normally.

There is a tab in front of no row in Column 2nd and two tabs in front of each row in column 3rd

 

Example

Original file

 
$CatAbbbbbcccccdddddeeeeefffff $CatBaaaaadddddeeeeeggggghhhhh

 

Comm
 
$ Comm a B aaaaabbbbbccccc ddddd eeeeefffff ggggg hhhhh $

Compare sorted files A and B

 

Comm-12
 
$ Comm-12A B dddddeeeee

Show only public rows

 

 

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.