Skip to content

Instantly share code, notes, and snippets.

@spscream
Last active December 19, 2015 23:59
Show Gist options
  • Select an option

  • Save spscream/6038059 to your computer and use it in GitHub Desktop.

Select an option

Save spscream/6038059 to your computer and use it in GitHub Desktop.
import sys,mmap;a=sys.argv;c=1
with open(a[2],'rb') as f:
m=mmap.mmap(f.fileno(),0,prot=1)
r=m.find(a[1])
o=len(m.read(r).split('\n')) if r>=0 else 0
print o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment