Skip to content

Instantly share code, notes, and snippets.

@cyu
Created March 21, 2009 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyu/82661 to your computer and use it in GitHub Desktop.
Save cyu/82661 to your computer and use it in GitHub Desktop.
#! /usr/local/bin/ruby
re = /^([\d.]+) (\S+) (\S+) \[([\w:\/]+\s[+\-]\d{4})\] "(.+?)" (\d{3}) (\d+) "([^"]+)" "([^"]+)"/
begin
while true
m = STDIN.readline.match(re)
puts "#{m[1]} #{m[4]}" if m
end
rescue EOFError
end
cat access_logs.20090319_1000.log | ./access_log_parser.rb | sed 's/19\/Mar\/2009:\(10:[0-9]*\).*/\1/' | sort -k 2,1| uniq -c | egrep -v '\s*1 ' | less
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment