Skip to content

Instantly share code, notes, and snippets.

@gleicon
Created February 16, 2016 00:38
Show Gist options
  • Save gleicon/bc5a3b3480835c36b59e to your computer and use it in GitHub Desktop.
Save gleicon/bc5a3b3480835c36b59e to your computer and use it in GitHub Desktop.
tail in python
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