Article Figure 1 Figure 2 Figure 3 Figure 4
Figure 5 Listing 1 Listing 2 Listing 3 Listing 4 apr2005.tar

Listing 3 Summary.sh

#!/bin/ksh
#*********************************************************************
# Listing 3
#
# File :  Summary.sh
#
# Description:
#
# This file takes the file output of chrt.sh  and shows some quick stats
# (Monthly High, Low, Average, Sum, and number of Successful days):
#  
# Author: John Ouellette
#
#*********************************************************************

#
#
if [ -z "$1" ];then
echo syntax $0 file 
exit
fi

#Vars
Sumfile=$1
Data=Data.txt

#Get numbers column
cat $Sumfile | cut -d ":" -f2  | grep [0-9] > $Data


#Sum  Data
Sum=0
while read line
do
        ((Sum+=line))
done <  $Data


#Calculate Stats
Days=`cat $Sumfile | cut -d ":" -f2 | grep [0-9] | wc -l` 
High=`cat $Sumfile | cut -d ":" -f2 | grep [0-9] | sort | tail -1` 
Low=`cat $Sumfile  | cut -d ":" -f2 | grep [0-9] | sort | head -1` 
let Avg=$(( $Sum / $Days ))


echo Sum : $Sum 
echo Avg : $Avg
echo Days: $Days 
echo High: $High 
echo Low: $Low

rm $Data
#*********************************************************************