APPLDIR=/ran
DATADIR=/usr/ran
t=/tmp/t
t2=/tmp/t.2
t4=/tmp/t.4
t5=/tmp/t.5
links=`cat $t5`
echo Z | awk -F: ' BEGIN {
j=0
k=0
t=0
}
FILENAME==ARGV[1] {
if ($1 <50 ){
z=sprintf ("%s%d",$4,NR-1)
x1[z]=$1
x2[z]=$2
x3[z]=$6
x4[z]=$5
}
next 
}
!t { var=FILENAME
t=1
lx=length(z) -1
 }
FILENAME==var {
y1[j]=$1
y2[j++]=$2
next
}
{
	j++
	
	for (k in x1)
	{
		v=substr(k,1,lx)
		if (v==var) 
		{
		
			l1[k] =y1[0]*6+1
			for (i=1;i<j;i++)
			{
				if(y1[i]==x2[k]) le[k]=l[k]
				l[k] +=y2[i]
			}
		}
	}
	var=FILENAME
	j=0
}
END { for (i in  x1 ) printf "%d:%s:%d:%d:%d\n",x1[i],x4[i],l[i]+l1[i],le[i],x3[i]
} ' $t4 $links - >>$t2


