Search a file for patterns from another file to another with awk

view full story

http://www.unix.com – Hi all ! I have 2 files: file1: Code: 1|AAA|123456 2|BBB|098765432 ... file2: Code: -|klk|AAA|$123.00|Qty.2|US -|opi|EEE|$23.00|Qty.4|US ... Output: Code: 1|AAA|-|klk|AAA|$123.00|Qty.2|US I would need to search the 3rd field of file2 for the patterns contained in the 2nd field of file1. And then, for the matching lines, return fields 1 and 2 from file1 followed by the entire line of file2. I tried several variants of the code below but don't know how to define the different fields from different files: Code: awk 'BEGIN{FS=OFS="|"}{NR==FNR}{a[$ (HowTos)