This shell script is for future reference. Used to copy zip apache log files into a temporary directory by day/month. Log files are unzipped and then searched for the strings we are looking for. It could be tidied up!
#!/bin/bash
PATHTOLOGS=/mypath/to/logs/www
WORKINGDIR=/tmplogs
YEAR=2009
MONTHS=(2009-01 2009-02 2009-03 2009-04 2009-05 2009-06 2009-07 2009-08 2009-09)
for MONTH in ${MONTHS[@]}
do
for LOGFILE in $(ls $PATHTOLOGS/$YEAR/$MONTH-??.access_log.gz)
do
echo “Checking: $LOGFILE”
cp $LOGFILE $PATHTOLOGS$WORKINGDIR
WORKINGLOG=`basename $LOGFILE`
gunzip $PATHTOLOGS$WORKINGDIR/$WORKINGLOG
UNZIPPEDFILE=`basename $WORKINGLOG .gz`
egrep “Media,1234,en.pdf|Media,1235,en.pdf|Media,1236,en.pdf” $UNZIPPEDFILE
\rm $PATHTOLOGS$WORKINGDIR/$UNZIPPEDFILE
done
done