From: Robert Klemme Date: 2009-10-09T05:50:04+09:00 Subject: Re: find a print out a line On 10/08/2009 10:15 PM, Collin Moore wrote: > I am slowly learning Ruby and working on a solution. I have huge text > files with tons of garbage and I want to extract just specific lines > including the word 'TestPhase'. > > Looking for simple solutions, just struggling with the problem. If you only need to extract those lines the most efficient solution is probably fgrep TestPhase If you want to do it in Ruby you can do ruby -ne 'puts $_ if /TestPhase/' If you need to further process those lines you can do ARGF.each |line| if /TestPhase/ =~ line # ... puts line end end There are probably plenty other options. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/