#!/bin/sh start_secs=$(date +%s) n=0 peak_sec_count=0 while read m d t host line; do log_sec=$(date -d "$m $d $t" +%s) if [ $n = 0 ]; then start_sec=$log_sec this_sec=$log_sec fi if [ $this_sec = $log_sec ]; then this_sec_count=$((this_sec_count+1)) else this_sec_count=0 fi if [ $this_sec_count -gt $peak_sec_count ]; then peak_sec_count=$this_sec_count fi elaps_sec=$((log_sec-start_sec)) if [ $elaps_sec -gt 0 ]; then avg=$(($n/(log_sec-start_sec))) fi this_sec=$log_sec n=$((n+1)) #echo $log_sec $avg $this_sec_count $line done spent_secs=$(($(date +%s)-start_secs)) echo "$n log entries over an elapsed time period of $elaps_sec seconds with a peak of $peak_sec_count records per second and an overall average of $avg records per second" echo "processed $n log entries in $spent_secs seconds at a rate of $((n/spent_secs)) records per second"