Comm for learning linux commands based on scenarios

Source: Internet
Author: User
I learned linux commands in combination with the scenario. comm asked me a question today. the model is such A set A-set B how to do it in linux. set A is placed in data1, and set B is placed in data2. what she started with was that the common-2-3data1data2 looked like it was normal...
I learned linux commands in combination with the scenario. comm asked me a question today. the model is such A set A-set B how to do it in linux. set A is placed in data1, and set B is placed in data2. in her first practice, the common-2-3 data1 data2 seems to be normal. -2 suppress column 2 (lines unique to FILE2)-3 suppress column 3 (lines that appear in both files)-2: indicates that the second column is not output (only in FILE2) -3: The third column is not output (both FILE1 and FILE2 are displayed, that is, the intersection of set A and set B ). after man comm, she found a simple error. www.2cto.com comm-compare two sorted files line by linecomm requires files to be ordered. we recommend that you use sort to get the desired result. here we provide A method to remove A-set B except comm. cat FILE1 FILE2 FILE2 | sort | uniq-u the principle is simple: when FILE2 appears twice, the elements in FILE2 must be repeated, if the file element in FILE1 is the same as that in FILE2, it will be removed by uniq-u.
 
Related Article

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.