view log/calc_avg.sh @ 14:e9e76fc32ef8 default tip

Fixed slide
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Mon, 03 Feb 2014 05:46:23 +0900
parents ff237e0f2e40
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