awk -F";" ' {
 printf "H01%s\n",$2
 printf "H02%s\n",$3
 printf "H03%s\n",$4
 } ' tmp/REGIONES > /tmp/RRGG

awk -F^ ' substr($1,1,2) == "'"$i"'" {
 printf "D%.2d00%s\n",++z-1,substr($1,3) 
 printf "D%.2d01%s\n",z-1,$2
 } ' tmp/COMUNAS >> /tmp/RRGG

ihmu regiones /tmp/RRGG -N1

done
