Skip to content

Instantly share code, notes, and snippets.

@entropie
Last active January 24, 2022 17:34
Show Gist options
  • Save entropie/bb20256de928fb3ca68daadda57e688c to your computer and use it in GitHub Desktop.
Save entropie/bb20256de928fb3ca68daadda57e688c to your computer and use it in GitHub Desktop.
quickNdirty: get a list of all urls with statuscode 404 from apache-format logfiles with the number of occurrence
#!/usr/bin/ruby
# ruby 404grep.rb /path/to/apache/logfile
require "pp"
LOGFILE = ARGV.join
resH = Hash.new{ |h,k| h[k] = 0 }
all404 = File.readlines(LOGFILE).grep(/404/)
all404.each{ |line|
url = line.split(" ")[6]
resH[url] += 1
}
pp resH.sort_by{ |k,v| v }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment