I am having trouble matching *two* strings from one file anywhere in a line of a second file, and could use some help getting this figured out. My preference would be to use grep for this because I would like to take advantage of its -A option. The latter is due to the fact that I would like both of the two strings from File1 to be found anywhere in the same line of File2, and then return the trailing n lines. A small sample from my data with desired output is as follows:
File 1:
PS001,001 HLK
PS002,004 MWQ
PS004,002 RXM
PS004,006 DBX
PS004,006 SBR
File2
PS001,001 [VWB-WHJ <Su>] [L-GBR> <PC>]
Lexeme VWB HJ== # L GBR #
PhraseType 2(2.1,7) 5(5,2.3)
PhraseLab 502[0] 521[0]
ClauseType NmCl
PS001,001 [D-<Re>] [B->WRX> D-<WL> <Co>] [L> <Ng>] [HLK <Pr>]
Lexeme D # B >WRX D <WL # L> # HLK #
PhraseType 6(6) 5(5,2.3,5,2.3) 11(11) 1(1:2)
PhraseLab 519[0] 504[0] 510[0] 501[0]
ClauseType xQt0
PS001,001 [W-<Cj>] [B-R<JN> D-XVJ> <Co>] [L> <Ng>] [QM <Pr>]
Lexeme W # B R<JN D XVJ # L> # QWM #
PhraseType 6(6) 5(5,2.3,5,2.3) 11(11) 1(1:2)
PhraseLab 509[0] 504[0] 510[0] 501[0]
ClauseType WxQ0
Desired Output:
PS001,001 [D-<Re>] [B->WRX> D-<WL> <Co>] [L> <Ng>] [HLK <Pr>]
Lexeme D # B >WRX D <WL # L> # HLK #
PhraseType 6(6) 5(5,2.3,5,2.3) 11(11) 1(1:2)
PhraseLab 519[0] 504[0] 510[0] 501[0]
ClauseType xQt0
I was hoping there was a way that I could use something like the following, which works great if there was only one string in File 1, rather than two.
grep -f -A4 File1 File2
I have tried various awk solutions, put this makes printing the match along with the following lines overly complicated (so it seems to me). Thanks in advance for any help you'd be willing to give.