Apache Access Log Summary

Log parsers and traffic analyzers like awstats and piwik are great, but sometimes I want a really quick way to see what pages were visited and by whom in a given day. Email is convenient for me and as I review a number of logs there every morning, I thought having this Apache summary there as well would be nice. Use as you wish and let me know if you have any suggestions for improvement.

if [[ -z $1 || -z $2 ]]
cat << EOF

A simple script to display, or optionally email, a breif output of the pages visited in a given day.

usage: $0 [logfile] [datestring] <1>

* Can only display as far back as the current log file for the given host. i.e. it won't pull data from rolled over log files
* Works with standard Apache log files


  [logfile] Required. The full path of the http access log file that you want to review
  [datestring]  Required. e.g. 2013-12-17 or \$(date --date="1 day ago" +\%Y-\%m-\%d) for a nightly cronjob
  <email>   Optional. Enter an email address to produce an email instead of displaying to standard out. Useful for a nightly cronjob


function output() {
grep $(date --date="$2" +%d/%b/%Y) $1 \
  | grep -v "bot\|feedafever.com\|css\|Ezooms\|\/js\/\|favicon.png\|apple-touch-icon.png\|\ 301\ \|\ 302\ " \
  | awk -F " " '{print $4 " " $1 " " $7}' \
  | sed 's/\[//' \
  | sed 's/google.*/google.com\"/' \
  | sed 's/bing.*/bing.com\"/' \
  | sed 's/https...\|http...//' \
  | uniq

if [[ -z $3 ]]
  output $1 $2
  output $1 $2 | mail -s "$(basename $1)" $3