日期:2014-05-16 浏览次数:20704 次
$] cat A.txt
------解决方案--------------------
sed -e "s/^.\{2\}\(.\{5\}\).*/\1/"
------解决方案--------------------
sort -g
36055
39055
54000
#!/bin/sh
sum=0
num=0
cat gcount1390451.07
------解决方案--------------------
while read line
do
x=`echo $line
------解决方案--------------------
cut -d\ -f9`
sum=`echo "$sum + $x"
------解决方案--------------------
bc -l`
num=$(($num + 1))
echo "sum=$sum" > /dev/shm/avg.tmp
echo "num=$num" >> /dev/shm/avg.tmp
done
. /dev/shm/avg.tmp
echo "sum=$sum"
echo "num=$num"
avg=`echo "$sum / $num"
------解决方案--------------------
bc -l`
echo "avg=$avg"
$] ./1.sh
sum=27.10
num=3
avg=9.03333333333333333333
awk '{print substr($0,3,7)}' urfile
------解决方案--------------------
sort
awk '{s+=$9}END{print s/NR}' urfile