class Rake::FileList

def egrep(pattern, *options)

standard out. Returns the number of matched items.
a standard emacs style file:linenumber:line message will be printed to
name, line number, and the matching line of text. If no block is given,
block is given, call the block on each matching line, passing the file
Grep each of the files in the filelist using the given pattern. If a
def egrep(pattern, *options)
  matched = 0
  each do |fn|
    begin
      open(fn, "rb", *options) do |inf|
        count = 0
        inf.each do |line|
          count += 1
          if pattern.match(line)
            matched += 1
            if block_given?
              yield fn, count, line
            else
              puts "#{fn}:#{count}:#{line}"
            end
          end
        end
      end
    rescue StandardError => ex
      $stderr.puts "Error while processing '#{fn}': #{ex}"
    end
  end
  matched
end