From: Robert Klemme Date: 2010-07-22T15:35:14+09:00 Subject: Re: finding last line in a file On 07/22/2010 07:10 AM, Urabe Shyouhei wrote: > (2010/07/22 14:08), Urabe Shyouhei wrote: >> Take a look at the doc for File.readline. > > Oops... typo. I meant readlines. With it you can do something like > File.readlines(f).last This is as inefficient as using File.foreach because it will read the whole file. I believe Ted was looking for a more efficient solution. Ted, if you want to do this in Ruby and not resort to tail you can use IO#seek to seek to the end of the file and read backwards until you have read more than one line. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/