I have two text files which are similar but with different tags:
Ben|2 Jen|4 Harry|8 Bill|3 Jack|2 Jill|2 Rip|1 P|1 A|3 B|4 C|2 G|5 Tom|1 Harr|4 Red|4 Green|2 Red|3 Blue|4 Lent|4 Burrow|2
Ben|2 Jen|5 Harry|2 Bill|4 Jack|3 Jill|6 Rip|1 P|2 A|19 B|0 C|1 G|2 Tom|3 Harr|2 Red|3 Green|4 Red|3 Blue|4 Lent|4 Burrow|2
Objective is to read both the files and whenever I see a word with tag "something" in File 1 and need to printout the word with the tag given in file 2.
But whenever I see a word with tag "4" in file 1 like this:
from file 1: Tom|1 Harr|4 Red|4 Green|2
Output should be:
etc Tom|3 Harr|2 Red|3 Green|4 Tom|3 Harr|2 Red|3 Green|4 etc
Basically if I see a tag 4in file 1 I need to generate multiple copies of my block in file2.
How can I do it?