Josh Cheek wrote in post #1017371:
>
> In Ruby:
> Dir["**/*.txt"].each do |filename|
>   lines = File.readlines(filename).grep(/your string here/)
>   p filename => lines unless lines.empty?
> end
>

Or something like this:

dir_path = '/path/to/dir'
str = "some string"

Dir.chdir(dir_path) do
  Dir.glob("*") do |filename|
    IO.foreach(filename) do |line|
      if line =~ /#{str}/i
        puts "#{filename}: #{line}"
      end
    end
  end
end

-- 
Posted via http://www.ruby-forum.com/.