find files grep pattern in ruby
.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