要如何用awk比較二個檔案欄位 - Linux

By Bennie
at 2017-12-25T16:19
at 2017-12-25T16:19
Table of Contents
我想用awk比較二個檔案,其中的某個欄位是否一致
二個檔案的內容分別是
file1
============
abc 1234
bcd 3456
def 7890
file2
============
abc 1234
bcd 8888
def 7890
我想要filter的是把第一欄做為index,當file2的第二欄有變動時
要能夠filter出來
bcd 8888
目前可以透過下面語法filter出來
awk 'NR==FNR{c[$2]++;next};c[$2] == 0' file2 file1
但如果是因為file1整筆紀錄是沒有的也會被filter
我想做的是當file1有bcd這欄,file2也有這筆紀錄,且第二欄是不一致的情況下
才會被filter出來,請問一下用awk如何才能夠達到?
ex:
file1
============
abc 1234
def 7890
file2
============
abc 1234
bcd 8888
def 7890
--
Tags:
Linux
All Comments

By Skylar DavisLinda
at 2017-12-27T08:28
at 2017-12-27T08:28

By Elvira
at 2017-12-28T09:45
at 2017-12-28T09:45

By Susan
at 2018-01-02T05:32
at 2018-01-02T05:32

By Daniel
at 2018-01-02T19:01
at 2018-01-02T19:01

By Mary
at 2018-01-06T07:40
at 2018-01-06T07:40

By Catherine
at 2018-01-08T17:30
at 2018-01-08T17:30

By Michael
at 2018-01-10T19:19
at 2018-01-10T19:19

By Anthony
at 2018-01-14T03:01
at 2018-01-14T03:01
Related Posts
Ubuntu PXE 開機後沒網路

By Joe
at 2017-12-22T10:08
at 2017-12-22T10:08
Ubuntu PXE 開機後沒網路

By Madame
at 2017-12-22T09:32
at 2017-12-22T09:32
cic更換license問題

By Erin
at 2017-12-20T16:36
at 2017-12-20T16:36
多nginx log檔案合併排序

By Margaret
at 2017-12-20T16:08
at 2017-12-20T16:08
Jetty https with wildcard

By Skylar DavisLinda
at 2017-12-20T09:30
at 2017-12-20T09:30