File: tail.rb

package info (click to toggle)
ruby-file-tail 1.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 208 kB
  • sloc: ruby: 890; makefile: 3
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