Last active
January 24, 2022 17:34
-
-
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
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/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