File1 has data as below ,
is the field separator
1,T_EXIT,9053.0,10325.0,, ,
2,V_TURN,120.0,11334.0,, ,
3,Q_ENTRY,122.0,190.0,, ,
4,Q_ENTRY_RUN,130.0,569.0,, ,
File2 has data
VDS SYNC
Dig T_EXIT OPEN
Ana Q_ENTRY CLOSE
Dig CORE_T
I want to compare column2 of file2 with column2 of file1 and if EXCAT MATCH is there I want to copy column3 from file2 in column6 and column7 in file1
I want output as:
1,T_EXIT,9053.0,10325.0,,OPEN,OPEN
2,V_TURN,120.0,11334.0,, ,
3,Q_ENTRY,122.0,190.0,,CLOSE,CLOSE
4,Q_ENTRY_RUN,130.0,569.0,, ,
I tried below code, but I could not get desired output. What correction needed.
awk 'NR==FNR{A[$2]=$3;next}$2 in A{$6=A[$2]}1' file2 file1 > test