Tente isto:
$ awk '
FNR == NR {if (FNR > 2) { k[$1] } next}
FNR > 2 {
id[$1] = ($1 in id) ? id[$1] = id[$1]"\n"$0 : id[$1] = $0;
if ($2 ~ /KEY/) { v[$1] = $3 };
next;
}
1
END {
for (val in v) {
if (v[val] in k) {
print id[val];
}
}
}
' keys features
ID FEATURE VALUE
-- ------- -----
A num_user 10
A KEY 4
B num_user 2
B KEY 2
B battery Large
D num_user 2
D KEY 2
D battery Small