Reputation: 3022
In the below awk
I am trying to remove those lines in f2
$1
that do not match f1
$1
. The awk
does execute but it prints all the lines not the desired output. Thank you :).
awk
awk 'FNR==NR{map[$1]=1;next;}map[$1]==$1{print;}' f1 f2
f1
ACTA2
ADA
AIP
f2
ADA
AG11
AIP
desired
ADA
AIP
Upvotes: 0
Views: 240
Reputation: 11207
Using awk
$ awk 'NR==FNR {array[$1]=$1; next} {if($1 == array[$1]) print}' file1 file2
ADA
AIP
Upvotes: 1