I want to replace specific fields in file (separated by ,) with fields from other file Fields which needs to be replaced will be found after matching different fields of same files. e.g.
cat test1.dat
12345,98765,aaaa,bbbbb
12346,98766,cccc,ddddd
cat test2.dat
12345,something,something,something,something,something,98765,something,something,somethi
12345,something,something,something,something,something,45655,something,something,somethi
12346,something,something,something,something,something,98766,something,something,somethi
12346,something,something,something,something,something,44556,something,something,something
Output file
cat test3.dat
aaaa,something,something,something,something,something,bbbbb,something,something,somethi
12345,something,something,something,something,something,45655,something,something,somethi
cccc,something,something,something,something,something,ddddd,something,something,somethi
12346,something,something,something,something,something,44556,something,something,somethi
in above example we are checking
if ($1 of test2.dat == $1 of test1.dat && $7 of test2.dat == $2 of test1.dat )
then
($1 of test2.dat = $3 of test1.dat)
($7 of test2.dat = $4 of test1.dat)
test1.dat will have distinct values of $1 and $2
test2.dat will be a huge file having millions of records
I am looking for solution which is fastest (we can even iterate through test1.dat and check for each row in test3.dat if it is fastest solution)
awkto the rescue!assumes file1 has unique keys
gives this