Created
December 28, 2012 03:29
-
-
Save ernestom/4394227 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# count duplicate entries in application log files | |
TMPDIR="/tmp/duplicates/" | |
APPDIR="/usr/local/sitios/" | |
cd $APPDIR | |
FILES=$(find ./ -path '*logs/2012*log' | sort -t '/' -k 5 | tail -n 1000); | |
rm -r $TMPDIR | |
mkdir $TMPDIR | |
for file in $FILES; do | |
DATEDAY=$(echo $file | awk -F '/' '{print $5 }') ; | |
FILECOUNT="$TMPDIR$DATEDAY"; | |
grep Duplicate $file | awk '{print $6}' >> $FILECOUNT; | |
done | |
for file in $(ls $TMPDIR | sort ); do | |
COUNT=$( cat $TMPDIR$file | sort | uniq | wc -l ); | |
DAY=$(echo $file | awk -F '.' '{print $1}'); | |
echo "$DAY\t$COUNT"; | |
done | |
cd - | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment