Você pode estar supercomplicando as coisas:
$ cat input
Record Info Interesting
123 apple yep
orange nope
lemon yep
-----------------------------------------------
456 dragonfruit yep
cucumber nope
-----------------------------------------------
789 kumquat nope
lychee yep
passionfruit yep
yam nope
-----------------------------------------------
987 grapefruit nope
$ awk 'BEGIN {OFS="\t"; print "Record","Info"} NF==3 && NR!=1 { number=$1 } NF!=3 && $2 ~ /yep/ {print number,$1}' input
Record Info
123 lemon
789 lychee
789 passionfruit
Para tornar o script awk
um pouco mais veritcal, para explicar como funciona:
BEGIN { # This block executes before any data
OFS="\t"; # are parsed, and simply prints a header.
print "Record","Info"
}
NF==3 && NR!=1 { # This block will run on any row (line)
number=$1 # with three fields other than the first
}
NF!=3 && $2 ~ /yep/ { # On rows with three fields where the second
print number,$1 # matches the regex /yup/, print the number
} # grabbed before, and the fruit.