From: Robert Klemme Date: 2006-03-11T21:58:44+09:00 Subject: Re: An Array of grep Results? Nathan Olberding wrote: > I want to search all the files in a directory for a string and save > the results in an Array. So far, the best solution I can come up with > is using system("grep ... > resultsFile"), then opening resultsFile > and doing readlines(). There's a better way, isn't there? # untested found = {} Dir["/foo/*"].each {|f| found[f] = File.open(f) {|io| io.grep(/your_string/)} } This should give you a hash with file names as keys and match lines as values. Kind regards robert