Dear Awk experts!
I have been trying to get a one liner for a match and merge operation, but having difficulties as I'm an awk newb. I always get stuck on the match and merge with 2 files.
I have 2 files as follows:
File 1:
field 1,field 2,field 3,field 4,field 5,field 6,field 7,field 8,field 9
1,first,yes,blah,1,a@b.com,m,12345,test 1
2,second,yes,this,1,b@c.com,n,22222,test 2
3,third,no,that,1,a@example.com,n,44444,test 4
4,fourth,no,ok,1,b@example.com,f,57657,test 3
File 2: (field separator is ":" in this file)
field 1:field 2
12345:additional1
44444:additional2
98777:additional3
So field 8 in file1 is matched with field 1 in file2.
If there is a match, then field 2 from file2 is appended to the end of the row in file 1.
So that the output looks like this:
field 1,field 2,field 3,field 4,field 5,field 6,field 7,field 8,field 9
1,first,yes,blah,1,a@b.com,m,12345,test 1,additional1
2,second,yes,this,1,b@c.com,n,22222,test 2
3,third,no,that,1,a@example.com,n,44444,test 4,additional2
4,fourth,no,ok,1,b@example.com,f,57657,test 3
If someone could provide a breakdown of the awk statement solution, this would also be very helpful for next time!
Thanks!