#!/usr/bin/env rubyrequire "set"def main stats = {} last_date = "" date = nil File.open(ARGV[0]) do |f| f.each_line do |line| # Finding the IP and date was too slow with regular expressions ip = line[0 ... line.index(" ")] str_date = line[line.index("[") + 1 ... line.index(":")] if str_date != last_date last_date = str_date m = [last_date[-4, 4], last_date[3, 3], last_date[0, 2]] date = Time.gm(*m) end if stats[date].nil? stats[date] = Set.new [ip] else stats[date] << ip end end end for date in stats.keys.sort puts "#{date.strftime("%d-%b-%Y")}\t#{stats[date].size}" endendif $0 == __FILE__ mainend