On 10 Dec 2002 12:09:13 -0800, geoflorida2000 / yahoo.com (George)
wrote:

>I want to write command line Ruby program whose arguments will be a 
> list of words to be found within all HTML documents of the current 
> directory. The output of the program will be a text file called 
> results.txt and will consist of a list of all HTML documents in which 
> one of the words appeared. Have the program create a subdirectory 
> called FINAL ,of the current directory and save results.txt there. 
> Finally, it will make duplicate copies of each of the files listed in 
> results.txt within the FINAL directory.
> Any help would be greatly appreciated
> George

something like this could work


#lil code, missing excepetion handling, one time runnable :-)
Dir.mkdir("./FINAL") 

File.open ("FINAL/result.txt", "w+") { |out|
  
 Dir["*.html"].each { |file| 
    IO.foreach(file) { |f|
     out.puts file if  f =~ /#{ARGV.join("|")}/  
     }
  }
}
IO.foreach "FINAL/result.txt" { |line|
system("mv #{line.chomp} FINAL/") 
}
#should handle this to be xplatform


Is nice whane you don't follow a Ruby programing course and get the
homework anyway ;)