From: Gregory Seidman Date: 2007-11-19T23:49:27+09:00 Subject: Re: Read last line of a file On Mon, Nov 19, 2007 at 11:38:08PM +0900, Shuaib Zahda wrote: > Hi all > > I was trying to find a method to read only the last line of a file. I > checked the the documentation and there is no such method. > Beside reading line after line and checking the the eof method. Is there > any faster or shorter way to do that. Depending on your platform, you might find that using popen with tail -1 will be the fastest and easiest way. Failing that, consider this: last = File.open(myfile) { |f| f.extend(Enumerable).inject { |_,ln| ln } } > Regards --Greg