Code:
awk '
NR==FNR{split($2,s,"/");i=s[2];a[i]=$3;next}
a[$7]{$0=$0 FS a[$7]}
{print}
' file2 file1
Explanation:
The code for the first file (
file2):
Code:
NR==FNR{split($2,s,"/");i=s[2];a[i]=$3;next}
NR==FNR -> is true when we read the first file.
split($2,s,"/") -> we split the second field to get the keys 2, 3 etc.
i=s[2] -> i is now the key
a[i]=$3 -> create an array "a" with the key as index and assign the value of the 3th field to the array
next -> read the next line and skip the rest of the code
The code for the second file (
file1):
Code:
a[$7]{$0=$0 FS a[$7]}
{print}
a[$7]{$0=$0 FS a[$7]} -> if the 7th field exists in the array append a fieldseperator and the value of the array after the line (this is the 3th field of the first file)
{print} -> print the line.
Hope this helps.
Regards