Rebhan, Gilbert
8/22/2007 10:27:00 AM
-----Original Message-----
From: Bertram Scharpf [mailto:lists@bertram-scharpf.de]
Sent: Wednesday, August 22, 2007 12:14 PM
To: ruby-talk ML
Subject: Re: tail, start reading at EOF
/*
Hi,
Am Mittwoch, 22. Aug 2007, 18:20:12 +0900 schrieb Rebhan, Gilbert:
> how to alter tail function to start at the end
> of the file, not reading the lines already existing in file ? =
file.seek 0, IO::SEEK_END
*/
thanks, with your pointer and an older post by Robert Klemme
i have a working solution now =
def tail(file, interval=1)
raise "Illegal interval #{interval}" if interval < 0
File.open(file) do |io|
io.seek 0, IO::SEEK_END
loop do
while ( line = io.gets )
puts line
end
# uncomment next to watch what is happening
puts "-"
sleep interval
end
end
end
Anything to improve ?
Regards, Gilbert