I have two files with the below contents :
sampleoutput3.txt
20150202;hostname1
20150223;hostname2
20150716;hostname3
sampleoutput1.txt
hostname;packages_out_of_date;errata_out_of_date;
hostname1;11;0;
hostnamea;12;0;
hostnameb;11;0;
hostnamec;95;38;
hostnamed;440;358;
hostnamee;439;331;
hostnamef;13;0;
hostnameg;17;3;
hostnameh;13;0;
I want to join second field of file : sampleoutput3.txt with first field of file : sampleoutput1.txt and then print fourth column of file : sampleoutput1.txt from the first column of file : sampleoutput3.txt in case match is found in a new file. So basically I expect four columns in the output file.
I tried below command but it didnt worked :
awk -F";" 'FNR==NR{A[$1]=$2;next} {print $0 OFS A[$1]}' OFS=";" sampleoutput3.txt sampleoutput1.txt
Could someone please help me with this. Please explain the same.
Thanks
Rahul