Skip to content

Instantly share code, notes, and snippets.

@mcrisc
Created April 27, 2010 13:29
Show Gist options
  • Save mcrisc/380726 to your computer and use it in GitHub Desktop.
Save mcrisc/380726 to your computer and use it in GitHub Desktop.
def filter(file_name, re_filter)
File.open(file_name) do |f|
f.each_line.with_index {|line, i| yield line, i if line =~ re_filter}
end
end
#re_filter = /HTTP-404/
re_filter = /ora-03113/i
filter('logs/error_log.1271160000', re_filter) do |line, i|
puts "#{i}: #{line}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment