#!/bin/bash
if [ -z "$1" ]
then
  echo "Usage: $0 <fidoconf.areas> [</path/to/stats/files>]"
  echo "   eg: $0 /etc/husky/areas /var/spool/ftn/stats/"
  exit 1
fi
shopt -s nocasematch
while IFS='' read -r line || [[ -n "$line" ]]
do
  if [ $( echo "$line" |grep -ci 'echoarea' ) -gt 0 ]
  then
    echotag=$(echo "$line" |sed 's/\s\+/ /g' |cut -d' ' -f2)
    echofile=$(echo "$line" |sed 's/\s\+/ /g' |cut -d' ' -f3)
    echotype=$(echo "$line" |sed 's/\s\+/ /g' |sed 's/.* -b *\([[:alnum:]]\+\) .*/\1/')
    if [[ "$echotype" == "jam" ]] || [[ "$echotype" == "squish" ]] || [[ "$echotype" == "msg" ]]
    then
      echo "Area $echotag $echotype $echofile ${2}${echotag}.stt"
    fi
  fi
done < "$1"
