(1) Read a source file (a single file of 1.2 million rows in it )
(2) Read Destination files one by one and replace the content ( few fields in it ) with the corresponding matching field from source file.
I tried as below: ( please note I am not posting the complete code and just a sue-do code )
awk -F"|" 'NR==FNR { array[$1]=$2;next } {gsub('fields in dest file',array[field positions in dest file]),$0 }
source_file dest_files*.dat
The flaw in the above code is , irrespective of whether there is a matching string or not , the row is getting printed and performance is also not good.
I got the issue resolved myself and forgot to update here.
The logic I used is:
awk -F"|" 'BEGIN{ read the source file and store in array} { for each record in dest file search and replace it with source data ( stored in array ) and save it to a file }' source_file dest_files*.dat