This method is deprecated or moved on the latest stable version.
The last existing version (v2_2_9) is shown here.
egrep(pattern, *options)
public
Grep each of the files in the filelist using the given pattern. If a block
is given, call the block on each matching line, passing the file name, line
number, and the matching line of text. If no block is given, a standard
emacs style file:linenumber:line message will be printed to standard out.
Returns the number of matched items.
# File lib/rake/file_list.rb, line 289
def egrep(pattern, *options)
matched = 0
each do |fn|
begin
open(fn, "r", *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