Created
February 11, 2019 21:38
-
-
Save dmerrick/e062731ed309b1d21f99ca08576132f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'pp' | |
require 'awesome_print' | |
# example_line = 'www-c8.proxy.aol.com - - [31/Aug/1995:23:59:52 -0400] "GET /icons/unknown.xbm HTTP/1.0" 200 515' | |
# line = example_line | |
results = {} | |
File.open(ARGV.first, "r") do |f| | |
f.each_line do |line| | |
begin | |
parts = line.split(/ /) | |
rescue Exception => e | |
puts "caught an error!" | |
puts "line:" | |
puts line | |
pp e | |
next | |
end | |
# ap parts | |
size, path = parts[-1], parts[-4] | |
results[path] ||= 0 | |
results[path] += size.to_i | |
end | |
end | |
sorted_results = [] | |
sorted_results = results.to_a.sort_by { |_, size| size } | |
sorted_results.each do |path, size| | |
puts "#{size}: #{path}" | |
end | |
# pp sorted_results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment