public
Last active

lines_per_day.rb

  • Download Gist
(1) lines_per_day.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12
#!/usr/bin/ruby
 
# Needed to figure out the daily load on our reporting server. Decided to hit the monthly log file
# and see how many lines per day were being written to it. This was a good excuse to test out some
# new Ruby learning.
 
logfile = ARGV[0]
101.upto(131) do |day|
day = day.to_s[1..2]
print "April #{day}:\t"
system("grep 201104#{day} #{logfile} | wc -l")
end
(2) sample bash session
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
dpritchett@LAP-DPRITCHETT ~/work
$ ./lines_per_day.rb ./Dtb_Freds_Planning_201104.log
April 01: 9886
April 02: 108
April 03: 83
April 04: 8293
April 05: 11893
April 06: 12408
April 07: 11832
April 08: 10948
April 09: 89
April 10: 148
April 11: 11320
April 12: 12858
April 13: 13582
April 14: 10867
April 15: 11040
April 16: 1100
April 17: 882
April 18: 12276
April 19: 11287
April 20: 12799
April 21: 1471
April 22: 0
April 23: 0
April 24: 0
April 25: 0
April 26: 0
April 27: 0
April 28: 0
April 29: 0
April 30: 0
April 31: 0
 
dpritchett@LAP-DPRITCHETT ~/work
$

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.