Hi,
I have stumbled upon many awk scripts which does merging of information from 2 files. I tried to use some of them for my task, but nothing really helped me in accomplishing my desired output
Here is what I am try to do ....
I have 2 files - main.txt and alternate.txt. Contents of main.txt is as given below -
A123|msg a 1|date a 1|other info a 1
B234|msg b 1|date b 1|other info b 1
C123|msg c 1|date c 1|other info c 1
D456|msg d 1|date d 1|other info d 1
.....
and so on
Contents of alternate.txt is as given below -
B234|1.1|msg b 2|remarks 1
B234|1.2|msg b 3|remarks 2
D456|1.1|msg d 2|remarks 1
D456|1.2|msg d 3|remarks 2
D456|1.3|msg d 4|remarks 3
D456|1.4|msg d 5|remarks 4
..... and so on.
Common key between the above files is column 1 (A123, B234, etc.). I want to consolidate the information available in the 2 files such that the result is as given below -
A123|msg a 1|date a 1|other info a 1
B234|msg b 1|date b 1|other info b 1
B234|1.1|msg b 2|remarks 1
B234|1.2|msg b 3|remarks 2
C123|msg c 1|date c 1|other info c 1
D456|msg d 1|date d 1|other info d 1
D456|1.1|msg d 2|remarks 1
D456|1.2|msg d 3|remarks 2
D456|1.3|msg d 4|remarks 3
D456|1.4|msg d 5|remarks 4
Basically, for every record which is present in main file, if there are any entries in alternate file, print those records subsequently in the result file. Any help with this is highly appreciated.
Thanks and Regards,
Vidya