join two files and adding coresponding fields at the end of delimited files

classic Classic list List threaded Threaded
1 message Options
oby
Reply | Threaded
Open this post in threaded view
|

join two files and adding coresponding fields at the end of delimited files

oby
Hi there,

i would like to learn this by myself, but my time is atm short and i need solution for this problem, two files:
cat file1 (i cannot control here if there was output with same number of lines. sometimes hostname6 is missing or some other hostname. what is constant here  is format of output but not number of lines)
hostname1;date;number;number
hostname2;date;number;number
hostname3;date;number;number
hostname4;date;number;number
hostname5;date;number;number
cat file2  (this is constant file and controllable)
person1;mail1;hostname3
person1;mail1;hostname4
person2;mail2;hostname1
person3;mail3;hostname2
person3;mail3;hostname5
person3;mail3;hostname6

so, for example it could happen that although there is hostname6 in second file i had no output for it in file1. But nonetheless i must get daily result and it should be this after merging for example above:
new file:
hostname1;date;number;number;person2;mail2
hostname2;date;number;number;person3;mail3
hostname3;date;number;number;person1;mail1
hostname4;date;number;number;person1;mail1
hostname5;date;number;number;person3;mail3

how to achieve this?
Thanks in advance!