[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 取出相同的行: [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
取出不同的行:
[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