comparison calc_avg.sh @ 0:28b900ca0be8 default tip

hg init
author Shoshi TAMAKI
date Mon, 11 Mar 2013 15:05:24 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:28b900ca0be8
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