I’ve been playing with a Ruby implementation of the *nix ‘tail’ command. Here’s
what I’ve come up with so far. I thought I’d put it out there for comment and see
what people think.
It doesn’t do anything fancy - it’s not nearly as smart as it’s Perl equivalent yet,
for example. But, it works.
Requires 1.7.2 (for the sysseek method).
While this is running, try doing
“echo ‘sometext’ >> test.txt” once in a while
t = Tail.new(“test.txt”) # Or whatever
Ctrl-C to exit
attr_accessor :file, :buffer, :interval
def initialize(file, buffer=8192, interval=10)
@file = file
@buffer = buffer
@interval = interval
@fh = File.open(file,"r") @fh.sysseek(-1,2)