Created
January 2, 2015 16:23
-
-
Save JaHIY/48103a399db830fabdff to your computer and use it in GitHub Desktop.
reverse file written in lua
This file contains hidden or 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
#!/usr/bin/env lua | |
--[[ | |
for line in io.lines(arg[0]) do | |
print(string.reverse(line)) | |
end | |
--]] | |
local file = io.open(arg[0], "r") | |
file:seek("end", -1) | |
while true do | |
io.write(file:read(1)) | |
if file:seek("cur", -2) == nil then | |
break | |
end | |
end | |
file:close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment