From: Joel VanderWerf Date: 2006-01-06T02:03:32+09:00 Subject: Re: Searching a file for keywords? Devin Mullins wrote: > Joel VanderWerf wrote: > >> puts IO.read('/proc/partitions').grep(/hda/) > > > puts open('/proc/partions/){|f|f.grep /hda/} > > Same number of characters, and much better memory usage for big files, > I'd imagine. You're quite right. Using grep on the File rather than on the string avoids slurping the whole file at once. (But it's not the same number of chars after you fix the typos! :) -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407