I need help in comparing two files using awk script. Compare second column of file1.csv to the first column of file2.csv, if matches print the row in the following expected format.
file1.csv
abc,id123,newyork
bcd,id456,seattle
file2.csv
id678,bbb,ccc
id123,hhh,ddd
expecte format:
abc,id123,hhh,newyork,{hhh,ddd},ddd
I am able to print up to the following so far
abc,id123,newyork,hhh,ddd
using the following awk,
$ awk -F, 'FNR==NR{f1[$2]=$0; next} $1 in f1 {print f1[$1] "," $2 "," $3}' file1.csv file2.csv