From: 7stud -- Date: 2007-11-10T09:54:18+09:00 Subject: Re: How to edit a file without loading it all into memory Jonathan Dobbie wrote: > 7stud -- wrote: >> Jonathan Dobbie wrote: >>> The lines are easy to >>> find with grep, and I'm able to create the new line easily enough, but >>> how can I do this without holding the entire file into memory? The >>> files can be hundreds of megabytes. >>> >> >> File.foreach("data.txt") do |line| >> #look for something in line >> end > > Here is what I originally wrote, and what I just tried. Am I missing > something obvious? The first one duplicates the lines, and the second > one does nothing. (doesn't save the changes) > 1) Are you under the impression that every method in ruby has the same parameters? 2) When you see an error message, do you just ignore it? -- Posted via http://www.ruby-forum.com/.