Um longo awk
oneliner:
awk '{keys[$2]=$1; filenames[FILENAME]++; values[FILENAME,$2]=$3}END{for (k in keys){printf("%s %s ", keys[k], k); for (f in filenames){printf("%s ", values[f,k]?values[f,k]:0)} printf("\n");}} ' File? | sort
Aqui está a saída, dados seus arquivos acima:
17 64298926 0.000599042 0 0
17 64298927 0.000399361 0 0
17 64298930 0 0 0.0016835
17 64298939 0 0 0.00117647
17 64298959 0 0.76087 0.0888383
17 64298980 0 0 0.00111359
17 64298992 0.000199681 0 0
17 64299003 0 0 0.0011236
17 64299014 0 0 0.00239234
17 64299026 0 0 0.00132626
17 64299030 0 0 0.00125628
17 64299039 0 0 0.00112867
17 64299041 0 0 0.00112108
17 64299058 0 0 0.00110619
17 64299101 0 0 0.00114155
17 64299103 0.000399361 0 0
17 64299123 0 0 0.00114943
17 64299131 0.000199681 0 0
17 64299152 0 0 0.00115741
17 64299360 0 0.75 0
17 64299462 0 1 0
17 64299584 0 0.5 0
Eu usei arbitrariamente um espaço como o separador de saída.
E aqui está o script desenrolado:
{
keys[$2]=$1;
filenames[FILENAME]++;
values[FILENAME,$2]=$3
}
END {
for (k in keys) {
printf("%s %s ", keys[k], k);
for (f in filenames) {
printf("%s ", values[f,k]?values[f,k]:0)
}
printf("\n");
}
}