From: Tim Hunter Date: 2008-12-21T01:14:08+09:00 Subject: Re: get first and last line from txt file - how? Yaser Sulaiman wrote: > On Sat, Dec 20, 2008 at 6:54 PM, Ch Ba wrote: >> It would work the same? Or do you mean without loading up the entire >> file? > > Yep, that is exactly what I mean. > If you know where the last line starts (that is, the byte offset of the first character in the last line) then you could use IO#seek to seek to that offset and then read. How do you know where the last line starts? When you write the file, call IO#tell to get the current byte offset before you write the last line. -- RMagick: http://rmagick.rubyforge.org/