I have two files Test1 and Test2.
Test1:
10AP23Q ERTY
10AP20J FDGC
978J15K BGTD
98KT23M ERTY
76VU14P FDGC
Test2:
23
19
15
Test1 is a fixed width file. If the column in Test2 found in line in Test1, insert ‘1’ , else insert ‘0’ at position 9 in Test1.
Expected output:
10AP23Q 1 ERTY
10AP20J 0 FDGC
978J15K 1 BGTD
98KT23M 1 ERTY
76VU14P 0 FDGC
I tried the below code. Getting parse error near '}'.
awk 'BEGIN {if('NR==FNR {a[$1];next} (substr($0,5,2) in a)' test2 test1) (substr($0,9,1)="1") else(substr($0,9,1)="0")}'
Appreciate the solution.