Apenas direcione a saída de seu comando awk
to sort
, mas anexe o cabeçalho após awk
processing.
awk '{FS = "\t" } $2 > 0 {
n[$1]++;
covered_bases[$1] += $3;
percentage_covered[$1] += $4;
}
END {
for (i in n) {
print i,covered_bases[i],percentage_covered[i];
}
}' $1 | sort | (echo 'Target covered_bases percentage_covered' && cat)