我有这个 awk 脚本:
!/NaN/{
nodes=$1;
range=$2;
size=$3;
frame=$4;
arrRate=$5;
type=$6;
pl=$7;
count[nodes,range,size,frame,arrRate,type,pl]++;
sumth[nodes,range,size,frame,arrRate,type,pl]+=$11;
sumdel[nodes,range,size,frame,arrRate,type,pl]+=$13;
sumdeliv[nodes,range,size,frame,arrRate,type,pl]+=$15;
sumthf[nodes,range,size,frame,arrRate,type,pl]+=$17;
sumdelf[nodes,range,size,frame,arrRate,type,pl]+=$19;
sumdelivf[nodes,range,size,frame,arrRate,type,pl]+=$21;
}
END{
for (i in count) {
split(i,sep,SUBSEP);
for (x in sep) {
printf "%s ", sep[x];
}
print sumth[i] / count[i],
sumdel[i] / count[i],
sumdeliv[i] / count[i],
sumthf[i] / count[i],
sumdelf[i] / count[i],
sumdelivf[i] / count[i],
count[i]
}
}
当我运行它时,mawk 1.3.3
我得到如下输出:
100 10 100 10 0.0001778279 DRAND 0.0 ...
但是当我运行时GNU Awk 3.1.5
,我得到:
10 0.0001778279 DRAND 0.7 100 10 100 ...
或第一列以不同的顺序打印。
是否有任何可靠的方法来迭代awk
数组的索引,以提供一致的输出,而不管 awk 版本如何?