Comm command Introduction

Source: Internet
Author: User

Usage: comm [Option]... file 1 file 2

Compare sorted files 1 and 2 row by row.

If no option is included,ProgramGenerates three output columns. The first column contains the rows specific to file 1, the second column contains the rows specific to file 2, and the third column contains the rows common to the two files.

①-1Does not output lines specific to file 1

②-2Do not output lines specific to file 2

③-3No rows are output for the two files.

-- Check-orderCheck whether the input is correctly sorted, even if all input rows are correct

-- Nocheck-orderDo not check whether the input is correctly sorted

-- Output-delimiter = STR by Str

Explanation:

1. -- check-order

Default command.If you do not want to check the sorting, you can -- nocheck-order.

2. -- output-delimiter = Str

STR is an expression.;It can be any non-special character.

3.Parameters can be mixed

-1,-2

It can be written as-12, which is the same as that used by Common commands.

Instance:

1.establish a.txt

Add Element

Apple

Orange

Gold

Silver

Steel

Iron

2. Establish B .txt

Add Element

Orange

Gold

Cookies

Carrot

You can try to directly compare:Comm a.txt B .txt

You will find an error with no sorting.

3. Sorting

Sort a.txt-O a.txt; sort B .txt-O B .txt

4. Comparison

$ Comm a.txt B .txt

The result is actually three columns. The first column is unique to file 1.-1 indicates that the first column is deleted.

The second column is unique to file 2.-2 indicates deleting the second column.

The third column indicates the common columns.-3 indicates that the common columns are deleted.

4.1 print the intersection:

$ Comm-12 a.txt B .txt

4.2 print different lines in two files

$ Comm-3 a.txt B .txt

Add a small modification. The two columns are not good-looking. Use sed to delete the \ t at the beginning of the row.

$ Comm-3 a.txt B .txt | SED's/^ \ t //'

Original

Http://www.16kan.com/post/195690.html

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.