#!/bin/sh

rm -f unsorted
for i in ../logs/*
do
  b=`basename $i`
  awk  '
/time:/{if ($3>1000) print 1000; else printf "%.0f\n", $3}
' $i/*.err|sort -n > $b
  solved=`awk '$1 < 1000{s++}END{print s}' $b`
  echo "$solved $b" >> unsorted
done
sort -r -n unsorted > summary

joined=/tmp/mktimes-joined
numbered=/tmp/mktimes-numbered
tmp=/tmp/mktimes-tmp
rm -f $joined
headers=""
while read solved name
do
  echo $solved $name
  nl $name > $numbered
  headers="$headers $name"
  if [ -f $joined ]
  then
    join $joined $numbered > $tmp
    mv $tmp $joined
  else
    mv $numbered $joined
  fi
done < summary
echo $headers > joined
cut -d\  -f 2- $joined >> joined
