Skip to content

Instantly share code, notes, and snippets.

@ernestom
Created December 28, 2012 03:29
Show Gist options
  • Save ernestom/4394227 to your computer and use it in GitHub Desktop.
Save ernestom/4394227 to your computer and use it in GitHub Desktop.
#!/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