awk '
{
if(common == "") {
fn=1 # field number
cn=1 # column number
tmp=$0
f=0
while(match(tmp,/*|$/) && f<=NF)
{ f+=1
cnA[fn]=cn # column number of start of field fn
cnZ[fn]=cn+RSTART-1 # column number of end of field fn
++fn
cn+=RSTART+RLENGTH-1
tmp=substr(tmp, RSTART+RLENGTH)
}
common = substr($0,1,cnA[7]-1)
dlim78 = substr($0,cnZ[7], cnZ[7]-cnA[7])
}
print $0
(f7+=$7)
(f8+=$8)
}
END {
p7=".0" # decimal places ($7)
p8=".7" # decimal places ($8)
pP=".7" # decimal places ($7*$8)
printf("%s%"p7"f%s%"p8"f%s%"pP"f\n" ,
common, f7/NR, dlim78, f8/NR, dlim78,f7*f8/NR)
}
' <<'EOF'
6 99999715 99999771 NM_001013399 0 - 23 0.0714286
6 99999715 99999771 NM_001013399 0 - 25 0.1250000
EOF
出力:
6 99999715 99999771 NM_001013399 0 - 23 0.0714286
6 99999715 99999771 NM_001013399 0 - 25 0.1250000
6 99999715 99999771 NM_001013399 0 - 24 0.0982143 4.7142864
これは、いくつかのawkの計算を示すための本当に便利な答えですが、要求された出力フォーマットを与えるものではありません。 –