Output different/identical rows in two files

Source: Internet
Author: User

Http://blog.csdn.net/wzhwho/article/details/6169603

[Root @ bb-sns-nac-test02 ~] # Cat f1.txt
Aaa
Bbb
CCC
Ddd
Eee
Fff
[Root @ bb-sns-nac-test02 ~] # Cat f2.txt
Ddd
Eee
Fff
Ggg
Hhh
Retrieve the same row: 
[Root @ bb-sns-nac-test02 ~] # Grep-WF f1.txt f2.txt
Ddd
Eee
Fff

[Root @ bb-sns-nac-test02 ~] # Grep-fxf f1.txt f2.txt
Ddd
Eee
Fff

Retrieve different rows:

[Root @ bb-sns-nac-test02 ~] # Grep-fvxf <(grep-fxf f1.txt f2.txt) f1.txt f2.txt
F1.txt: AAA
F1.txt: bbb
F1.txt: CCC
F2.txt: ggg
F2.txt: hhh
F2.txt:

[Root @ bb-sns-nac-test02 ~] # Grep-WVF f1.txt f2.txt
Ggg
Hhh

[Root @ bb-sns-nac-test02 ~] # Grep-WVF f2.txt f1.txt
Aaa
Bbb
CCC

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.