#!/usr/bin/env bash
c=1
while read line
do
a=( $line )
d="${a[@]::3}"
logdate=$( date '+%F' -d"$d" )
if [[ $logdate == $old_logdate ]]; then
(( c++ ))
elif [[ $old_logdate != $logdate ]]; then
printf "%s\t%s\t%s%s\n" "Date: $old_logdate Number of failed attempts: $c"
old_logdate=$logdate
c=1
continue
else
printf "%s\t%s\t%s%s\n" "Date: $logdate Number of failed attempts: $c"
fi
done < <(grep 'authentication failure' /var/log/secure)
é pular o último registro, não sei por que