find files grep pattern in ruby

| | TrackBacks (0)

.c( whytheluckystiff )o. -- Wearing Ruby Slippers To Work
nice short code demonstrates seraching files for a pattern.

Dir['**/*.php'].each do |path|
File.open( path ) do |f|
f.grep( /search_string/ ) do |line|
puts path, ':', line
end
end
end

0 TrackBacks

Listed below are links to blogs that reference this entry: find files grep pattern in ruby.

TrackBack URL for this entry: http://kennethhunt.com/mt/mt-tb.cgi/1328

About this Entry

This page contains a single entry by klsh published on March 22, 2005 9:54 AM.

Google of the future was the previous entry in this blog.

1-ounce silver coin, called the Libertad (Liberty) is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.