文本中有如下数据
22.19 11.162559 130 85767 PQsocket
14.54 7.066914 85 83103 PQsocket
26.25 13.066012 157 82725 PQsocket
14.91 7.074921 85 83082 PQsocket
18.16 9.080348 110 82548 PQsocket
17.89 9.024185 110 81747 PQsocket
22.26 11.009339 135 81081 PQsocket
24.62 11.017309 134 82062 PQsocket
25.20 11.006128 135 81285 PQsocket
18.97 8.919769 113 78894 PQsocket
计算每列平均数,昨天我用计算器一个个输的,累死了.今天弄了个脚本,如下,还不是太理想,每次还要更改.
for han in PQsocket selec PQgetResult
do
echo "$han"
echo -en "/40"
grep -i "$han" zzzz.txt |awk '{j+=$3
k++
printf("result:%f/t",j)
printf("average :%f/n",j/k)
}'
done
不过,也省了不少精力和时间^o^,有地方能改进的,请各位指教!