Reading the last n lines of a file in Ruby? September 25, 2023 by Tarik If on a *nix system with tail, you can cheat like this: last_25_lines = `tail -n 25 whatever.txt`