Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is a library for Ruby called <a href="https://github.com/flori/file-tail" rel="nofollow noreferrer">File::Tail</a>. This can get you the last N lines of a file just like the UNIX tail utility.</p> <p>I assume there is some seek optimization in place in the UNIX version of tail with benchmarks like these (tested on a text file just over 11M):</p> <pre><code>[john@awesome]$du -sh 11M.txt 11M 11M.txt [john@awesome]$time tail -n 25 11M.txt /sbin/ypbind /sbin/arptables /sbin/arptables-save /sbin/change_console /sbin/mount.vmhgfs /misc /csait /csait/course /.autofsck /~ /usb /cdrom /homebk /staff /staff/faculty /staff/faculty/darlinr /staff/csadm /staff/csadm/service_monitor.sh /staff/csadm/.bash_history /staff/csadm/mysql5 /staff/csadm/mysql5/MySQL-server-community-5.0.45-0.rhel5.i386.rpm /staff/csadm/glibc-common-2.3.4-2.39.i386.rpm /staff/csadm/glibc-2.3.4-2.39.i386.rpm /staff/csadm/csunixdb.tgz /staff/csadm/glibc-headers-2.3.4-2.39.i386.rpm real 0m0.012s user 0m0.000s sys 0m0.010s </code></pre> <p>I can only imagine the Ruby library uses a similar method.</p> <p><strong>Edit:</strong></p> <p>for Pax's curiosity:</p> <pre><code>[john@awesome]$time cat 11M.txt | tail -n 25 /sbin/ypbind /sbin/arptables /sbin/arptables-save /sbin/change_console /sbin/mount.vmhgfs /misc /csait /csait/course /.autofsck /~ /usb /cdrom /homebk /staff /staff/faculty /staff/faculty/darlinr /staff/csadm /staff/csadm/service_monitor.sh /staff/csadm/.bash_history /staff/csadm/mysql5 /staff/csadm/mysql5/MySQL-server-community-5.0.45-0.rhel5.i386.rpm /staff/csadm/glibc-common-2.3.4-2.39.i386.rpm /staff/csadm/glibc-2.3.4-2.39.i386.rpm /staff/csadm/csunixdb.tgz /staff/csadm/glibc-headers-2.3.4-2.39.i386.rpm real 0m0.350s user 0m0.000s sys 0m0.130s </code></pre> <p>still under a second, but if there is a lot of file operations this makes a big difference.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload