File: tail.rb

package info (click to toggle)
ruby-file-tail 1.0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 188 kB
  • sloc: ruby: 887; makefile: 5
file content (10 lines) | stat: -rwxr-xr-x 231 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
#!/usr/bin/env ruby

require 'file/tail'

filename = ARGV.pop or fail "Usage: #$0 number filename"
number = (ARGV.pop || 0).to_i.abs

File::Tail::Logfile.open(filename) do |log|
  log.backward(number).tail { |line| puts line }
end