I have a pretty specific question, and have been able to find lots on conditional subsetting using awk but none that lends enough explicit code for me to generalize to my situation. I have a file 'keys' and a file 'features'. The 'keys' table contains two variables, KEY and GROUP, toy example below.
KEY GROUP --- ----- 1 GROUP0 2 GROUP0 3 GROUP1 4 GROUP1 5 GROUP2 6 GROUP2
The file 'features' contains a list of features of widgets like so
ID FEATURE VALUE -- ------- ----- A num_user 10 A KEY 4 B num_user 2 B KEY 2 B battery Large C num_user 10 C KEY 15 D num_user 2 D KEY 2 D battery Small E num_user 2 E KEY 7 E battery Small
I am trying to select all rows for an ID which has a value of 'KEY' that is in the 'KEY' column of 'keys' for a hardcoded list of 'GROUP' values. The desired result is
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