Que tal algo como isto:
#!/bin/bash
LAST_OUTPUT=$(date +%s)
TMPFILE=$(mktemp)
INTERVAL=30
while read LINE; do
echo $LINE >> $TMPFILE
NOW=$(date +%s)
if [[ $(($NOW - $LAST_OUTPUT)) -gt $INTERVAL ]]; then
sort < $TMPFILE | uniq -c
echo -ne > $TMPFILE
LAST_OUTPUT=$NOW
fi
done
rm $TMPFILE