Below is the scenario. Help is appreciated.
File1: ( 500,000 lines ) : Three fields comma delimited : Not sorted
1234FAA,435612,88975
1224FAB,12345,212356
File2: ( 4,000,000 lines ) : Six fields comma delimited (Last 3 field should match the 3 fields of File1) : Not Sorted :
0123456abcd,12345,abcdef,1234FAA,435612,88975
0123456wxyz,11234,lmnopq,1224FAB,12345,212356
I need to grab all the six fields for file2 when there is a match of first 3 fields of file1 and last 3 fields of file2.
I wrote a small script but seems like it might take days to complete
1 \#!/bin/ksh
2
3 while read record
4 do
5 cat file2 | grep "$record" >> final.list
6 done < file1
Can someone help me with a faster solution?
Thanks in advance.