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
#*********************************************************************
|