From: Chris Shea Date: 2008-12-22T09:26:39+09:00 Subject: Re: get first and last line from txt file - how? On Dec 20, 7:16 am, Mmcolli00 Mom wrote: > I have txt file with date/time stamps only. I want to grab the first > date/time and the last date/time. For instance, I will be needing > 08/09/08 3:00 and 08/24/08 3:00 from the below queued.txt. Do you know > how I can pull these out? Thanks in advance. > > queued.txt > 8/09/08 3:00 > 8/10/08 5:00 > 8/23/08 22:00 > 8/24/08 3:00 > > firstDate = "" > lastDate = "" > > File.open('queued.txt', 'r') do |f1| >  while line = f1.gets >    if f1.lineno ==  1 then #<-this would only give me 8/09/08 3:00 >     @@fistDate = f1 >    end > end > -- > Posted viahttp://www.ruby-forum.com/. Aside from the suggestions already made for getting just the last line, there's also James Gray's Elif: http://elif.rubyforge.org/ HTH, Chris