$ file1.txt
12345,865221,APPLE,ZZ,QQ,DD,GG,APPLE-FRUIT
12346,865222,MANGO,ZZ,QQ,DD,GG,MANGO-FRUIT
12347,865222,GRAPE,ZZ,QQ,DD,GG,GRAPE-FRUIT
$file2.txt
APPLE-FRUIT,10KG
MANGO-FRUIT,12KG
I have two files as mentioned above. I need to create a new file, as given below.
$Output
12345,865221,APPLE,ZZ,QQ,DD,GG,APPLE-FRUIT,10KG
12346,865222,MANGO,ZZ,QQ,DD,GG,MANGO-FRUIT,12KG
12347,865222,GRAPE,ZZ,QQ,DD,GG,GRAPE-FRUIT
One method I worked out was using a while loop. I read each line of file2 and compare first column with 8th column of file1. This way I am able to get desired output. I am looking for a simple awk command to achieve the same.