Skip to content

Instantly share code, notes, and snippets.

@skinp
Created March 30, 2012 15:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save skinp/2252263 to your computer and use it in GitHub Desktop.
Save skinp/2252263 to your computer and use it in GitHub Desktop.
Tail -f implementation in python
import time
def tailf(filename):
f = open(filename, 'r')
f.seek(0,2)
while True:
line = f.readline()
if not line:
time.sleep(0.1)
continue
yield line
if __name__ == '__main__':
import sys
filename = sys.argv[1]
for i in tailf(filename):
print i,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment