Created
April 28, 2011 16:05
-
-
Save dpritchett/946651 to your computer and use it in GitHub Desktop.
Line count of daily logfiles in a given folder
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 | |
require 'date' | |
PATH = "//server_name/and/folder_path/redacted" | |
EXTENSION = 'txt' | |
# Parse out a date from each filename, print per-day line counts | |
Dir["#{PATH}/*.#{EXTENSION}"].each do |log_file| | |
return_value = '' | |
date_string = /\d{8}/.match(log_file).to_s | |
return_value << Date.parse(date_string).strftime("%Y/%m/%d\t") | |
open(log_file) { |f| return_value << f.lines.count.to_s } | |
puts return_value | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment