shell脚本学习---006(对于文本中数字的解析计算)

#!/bin/sh
allTime=0
iCounter=0
grep 'dedup time :' $1 |while read LINE
do
#echo "line is" $LINE
oneTime=`echo $LINE |awk '{print $10}'`
#echo "ont time is " $oneTime
allTime=`expr $allTime + $oneTime`
iCounter=`expr $iCounter + 1`
echo $allTime "count is" $iCounter
#sleep 1

done

echo $allTime "count is" $iCounter

 

读取文件中的每一行,然后计算特定位置上的数字的平均值 。

posted @ 2012-04-12 16:04  xiao晓  阅读(715)  评论(0编辑  收藏  举报