is not that simple if the date does not appear in the file because in that minute/hour doesn't log ?
---------- Post updated at 06:16 AM ---------- Previous update was at 05:43 AM ----------
Done
Code:
#!/usr/local/bin/bash
export PATH="$PATH:/usr/local/coreutils/bin"
#07/02/09 12:35:57
ADESSO=$(cdate "+%m/%d/%y %H:%M")
UNORAFA=$(cdate -d "1 hour ago" "+%m/%d/%y %H:%M")
UNORAFA_S=$(cdate -d "1 hour ago" +%s)
echo $ADESSO
echo $UNORAFA
echo $UNORAFA_S
A="0"
while [ "$A" -lt "61" ] ; do
echo $A
QUACK=$(grep -n "$UNORAFA" daemon.log|tail -1)
if [ "$QUACK" = "" ]; then
let A=$A+1
let UNORAFA_S=$UNORAFA_S+60
UNORAFA=$(cdate -d "@$UNORAFA_S" "+%m/%d/%y %H:%M")
echo devo provare $UNORAFA
else
echo TROVATO $UNORAFA
echo $QUACK
TOTAIL=$(echo $QUACK |awk -F\: '{print $1}')
NUMLINES=$(wc -l daemon.log|awk '{print $1}')
echo $TOTAIL
echo $NUMLINES
let TOTAIL=$NUMLINES-$TOTAIL
tail -$TOTAIL daemon.log > ESTRATTO.txt
A=61
fi
done