How can I replace multiple strings in one big file ( + 500K lines ) using a mapping file (+ 50K lines) ? The mapping file is structured like this :
A1 B1
A2 B2
A3 B3
.. ..
and the big file is structured like this :
A1 A2
A1 A3
A1 A8
A2 A1
A2 A3
A3 A10
A3 A13
and every string in the big file has to be replace using the mapping file.
Result wanted :
B1 B2
B1 B3
B1 B8
B2 B1
B2 B3
B3 B10
B3 B13
I tried using awk on every line of the mapping file but it takes a very very long time ... Here is the awk command. So I wrote a loop launching for each line of the mapping file an awk command, I save the results in a temporary file and use this result in a new awk with the next line of the mapping file ( not very efficient I know .. )
cat inputBigFile.txt | awk '{ gsub( "A1","B1" );}1' > out.txt
Thanks in advance
awkcommand did you try that was too slow?NR==FNR.catdata to programs that can read it itself, likeawk.awk '{ gsub( "A1","B1" );}1' inputBigFile.txt > out.txt. To see how long time program uses, start it withtimeeks:time awk 'codefile > out`