view calc_avg.sh @ 0:28b900ca0be8 default tip

hg init
author Shoshi TAMAKI
date Mon, 11 Mar 2013 15:05:24 +0900
parents
children
line wrap: on
line source

#!/bin/sh

function average() {
 total=0.0
 count=0
 while read time
 do
  total=`echo $total + $time | bc`
  count=`echo $count + 1 | bc`
 done
 avg=`echo "scale=4;$total/$count" | bc`
 echo "$count,$avg"
}

for arg in $@
do
 average < $arg
done