I have two files:
$ cat inds
2
5
3
$ cat family
1 2 3 4
1 5 3 4
1 3 0 0
1 4 0 0
1 7 0 0
1 6 2 7
1 8 2 7
I want to write a new file with all the records in family that are NOT in inds, but matching only in field 2 of family. I foolishly tried
grep -v -f inds family
But of course it matches anywhere in the line, and it removes the last two lines as well because they have the 2 in field 3.
awk '{if($2!="2" && $2!="3" && $2!="5") print $0}' family
would work if my real inds file was not hundreds and hundreds of lines long... So basically, I am looking for something that can inverse-match every pattern from a long long list of patterns, but only for field 2.
I hope this makes sense. Thank you.