Hi Guys,
I wanted to compare a delimited file and positional file, for a particular key files and if it matches then append the positional file with some data.
Example:
Delimited File
--------------
Byer;Amy;NONE1;A5218257;E5218257
Byer;Amy;NONE1;A5218260;E5218260
Positional File
--------------
190004000153E5218257010000000980002425852013
190004000153E5218258010000003850002425852013
190004000153E5218259010000012190002425852013
190004000153E5218260010000003850002425852013
190004000153E5218261010000012190002425852013
If the fifth filed in the delimited file is found in the positional file at position 13 then we have to append the fourth field from the delimited file into the positional file, at the end of the respective record.
Expected output
190004000153E5218257010000000980002425852013A5218257
190004000153E5218258010000003850002425852013
190004000153E5218259010000012190002425852013
190004000153E5218260010000003850002425852013A5218260
190004000153E5218261010000012190002425852013
Script Used
awk 'BEGIN{FS = ";"};FNR==NR{A[$5] = $4}
FNR!=NR{if ((x = substr($0,13,8)) in A) print $0 A[x];else print A[x]}' $1 $2 > $3
The above awk command is not working properly. It is not appending the desired data in the positional file.
Please help.
Thanks in advance!!
Thanks,
Ajay