From: Zion hardes Date: 2010-01-20T18:25:50+09:00 Subject: Re: help on a script --00151743f754f50493047d952b5d Content-Type: text/plain; charset=ISO-8859-1 elsif File.directory?(f) && File.basename(f) != '..' && File.basename(f) != '.' Maybe like this? :( On Wed, Jan 20, 2010 at 6:23 PM, Zion hardes wrote: > exclude . and .. in directories > > > On Wed, Jan 20, 2010 at 5:19 PM, Ruby Newbee wrote: > >> Hi, >> >> I just wrote a small script to find the files in current directory and >> its child directories which include the word "ruby". >> But it can't work, please help point out my error, thanks. >> >> >> def myfind(path=".") >> Dir.foreach(path) do |f| >> if File.file? f >> open(f) do |c| >> puts "#{path}/#{f}" if c.read.scan(/ruby/) >> end >> elsif File.directory? f >> newpath = File.join path,f >> myfind(newpath) >> end >> end >> end >> >> myfind >> >> > --00151743f754f50493047d952b5d--