APPLDIR=/ran
DATADIR=/usr/ran
t=/tmp/t
t3=$t.3
cd $DATADIR/calcu
hdsort /IHD/calcu/calcu h00: d00 | awk -F: ' {
x[$1]=x[$1]""$2
}
END { for (i in x ) if (x[i]!="") print i":"x[i] } ' > $t3
awk -F: ' BEGIN { h=-1;d=-1
getline
}
FILENAME == ARGV[1] { 
	if ($1=="H")
	{
		x="h"
		h++
		if ($4+0==30) c[$7]=sprintf ("%s%.2d",x,h)
		v[$2]=sprintf ("%s%.2d",x,h)
	}
	if ($1=="D")
	{
		x="d"
		d++
		if ($4+0==30) c[$7]=sprintf ("%s%.2d",x,h)
		v[$2]=sprintf ("%s%.2d",x,d)
	}
	print $2,v[$2]

	next
}

{
	for (j in c) if ( $1==j)
	{
		zz=$2
		l=length(zz)
		for (i in v)
		{
			print v[i],i,zz
			
			while (x=index(zz,i))
			zz=substr(zz,1,x-1)""v[i]""substr(zz,x+length(i))
		}
		print zz
	}
	} ' $t $t3 
