Read more

Parse & sort unique hits in logfiles

Thomas Eisenbarth
October 21, 2011Software engineer at makandra GmbH

If you want to know the exact hits on your website (or whatever logfile you want) for a specific date without duplicates, here's how.
"Unique" means you don't want to count hits to an URL originating from the same IP twice.

Illustration book lover

Growing Rails Applications in Practice

Check out our e-book. Learn to structure large Ruby on Rails codebases with the tools you already know and love.

  • Introduce design conventions for controllers and user-facing models
  • Create a system for growth
  • Build applications to last
Read more Show archive.org snapshot

You can use the attached script to do so:

# ./log_parser.rb 2011-10-04

27 hits on /rss.xml
36 hits on /stylesheets/fonts/slkscr-webfont.woff
37 hits on /stylesheets/fonts/slkscrb-webfont.woff
37 hits on /images/bullet.png
38 hits on /images/download.png
38 hits on /images/play.png
39 hits on /stylesheets/gameboy.css
39 hits on /stylesheets/screen.css
39 hits on /javascripts/jquery-1.6.1.min.js
43 hits on /images/hosts/x2/arne.png
43 hits on /images/hosts/x2/thomas.png
43 hits on /images/hosts/x2/henning.png
45 hits on /
46 hits on /images/die-nerdtanke-75x75.png
50 hits on /favicon.ico
260 hits on /podcasts/nerdtanke-8.mp3
Posted by Thomas Eisenbarth to makandra dev (2011-10-21 14:58)