Created
July 31, 2011 19:52
-
-
Save tsujigiri/1117141 to your computer and use it in GitHub Desktop.
Read a file line by line beginning at the last one
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file = File.open("some_file.txt", "r") | |
pos = file.size | |
file.pos = pos | |
while pos >= 0 | |
if file.readchar == "\n" | |
line = file.readline | |
# do something with line | |
end | |
pos -= 2 | |
file.pos = pos | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment