get the most visited url from an access log through a single line of bash

17 June 2015

If you have an apache access log and want to see the visit count of your site, you can use this one-liner to get some basic visit stats.

grep "200 " /var/log/apache2/apimeister-access.log \
  | grep -v 'Googlebot' \
  | grep -v 'Baiduspider' \
  | grep -v 'bingbot' \
  | grep -v 'YandexBot' \
  | grep -v 'MJ12bot' \
  | grep -v 'meanpathbot' \
  | grep -v 'DotBot' \
  | grep -v 'AhrefsBot' \
  | cut -d '"' -f 2 \
  | cut -d ' ' -f 2 \
  | sort | uniq -c | sort -rn | less