From: William James Date: 2007-09-08T15:20:08+09:00 Subject: Re: read a specific line from a file On Sep 7, 8:34 pm, Pe�a, Botp wrote: > From: rio4ruby [mailto:Christopher.Kleck...@gmail.com] > # Or even > # rio('test.txt').line[2] > > thanks. i just wanted (and hoped) that the op will try his hands on rio and experiment it. He ought to learn and experiment with Ruby first. > > rio has simple solutions for line grabbing, like eg, "get line 3..5, lines 100,200,300..400, and lines containing /test/" > > rio('test.txt').line[3..5,100,200,300..400,/test/] lines = IO.readlines("phrases_no_extra.txt") lines.values_at( 3..5,100,200,300..400 ) + lines.grep( /test/ )