From: drew Date: 2005-10-27T13:52:03+09:00 Subject: Newbie help: File searching and writing output to new file Hi people, I've done a bit of searching through this group, and found some things that I thought would help me, but unfortunately they haven't. I'm just trying to write a short script that will search through web server log files and write out lines from the original files that contain a certain term to a new file. I did have the "puts" line of my code working, but after a few changes that doesn't work either! What am I doing wrong?? : There are a bunch of "ex2005##.log" files in the current directory. -------------------- #!c:\ruby\bin\ruby def find_redir found = [] Dir['ex*.log'].each do |file| file.each_line do |line| #found.push line if line =~ /redir/ found.push line if line["redir"] #puts line if line["redir"] end File.open("found-redir-lines.txt", "w+") do |o| o.write found.join end #p found.join end end def show_500_errors f = File.open("found-redir-lines.txt", "r") f.each do |line| puts line if line["500"] end end find_redir() #show_500_errors() ------------------- The second function is to go through the new file and find 500 server errors, which I guess I could have done in the first function, but not to worry. So why does this produce a create a "found-redir-lines.txt" file, but leave it blank ?? Thanks in advance, rubyists Drew