Created
February 16, 2016 00:38
-
-
Save gleicon/bc5a3b3480835c36b59e to your computer and use it in GitHub Desktop.
tail in python
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
import sys | |
import time | |
def tail(tfile): | |
with open(tfile, 'r') as fp: | |
while True: | |
ll = fp.readline() | |
if ll: | |
print ll | |
else: | |
time.sleep(0.5) | |
if __name__ == "__main__": | |
if len(sys.argv) < 2: | |
print "tail.py <file>" | |
sys.exit() | |
tail (sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment