Ahmet Kilic wrote: > I need some help about keywords searching in directory and files. > > I have a directory > dirs--a > |--b > |--c > and files > a-->a1.txt > |-->a2.txt > |-->a3.txt > > I can lsit all files and directories like this, > > require 'find' > dirs = ['C:\\Users\\test\\dirs'] > keywords = ["keyword1","keyword2"] > for dir in dirs > Find.find(dir) do |path| > if FileTest.directory?(path) > if keywords.include?(File.basename(path)) > # make something here... and output the finding data > else > Find.prune # skip the files > next > end > else > puts path > end > end > end > > how can I do it and how can I print output the results in a text or csv > file? > Or need a plugin like Ferret? > please help me. To write to a file you need something like this: f=File.new("w","myfile.txt") f << "line 1" f << "line 2" f.close -- Posted via http://www.ruby-forum.com/.