comparison calc_avg.sh @ 0:580b2753e17c default tip

hg init
author Shoshi TAMAKI
date Wed, 20 Feb 2013 20:14:09 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:580b2753e17c
1 #!/bin/sh
2
3 function average() {
4 total=0.0
5 count=0
6 while read time
7 do
8 total=`echo $total + $time | bc`
9 count=`echo $count + 1 | bc`
10 done
11 avg=`echo "scale=4;$total/$count" | bc`
12 echo "$count,$avg"
13 }
14
15 for arg in $@
16 do
17 average < $arg
18 done