BASH - remove line if first column content appears in another file

Question!

If I have two files. File A looks like:

a 1
a 2
a 3
b 4
c 5

and I have file B which has content:

a
b

For everything that appears in file B and also appears in column 1 in file A, I would like to remove those lines. So the expected output for file A should be:

c 5

Any help is greatly appreciated!



Answers

The following will do the work,

awk 'FNR==NR{map[$1]=1;next;}map[$1]==""{print;}' 


GNU Awk:

awk 'ARGIND == 1 { del[$0]   } ARGIND == 2 
By : Kaz


This video can help you solving your question :)
By: admin