How to read a file from bottom to top in Ruby?

后端 未结 3 2030
灰色年华
灰色年华 2020-12-09 12:04

I\'ve been working on a log viewer for a Rails app and have found that I need to read around 200 lines of a log file from bottom to top instead of the default top to bottom.

3条回答
  •  生来不讨喜
    2020-12-09 12:22

    There's a module Elif available (a port of Perl's File::ReadBackwards) which does efficient line-by-line backwards reading of files.

提交回复
热议问题