Skip to content

Instantly share code, notes, and snippets.

@yousefamar
Created September 26, 2014 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yousefamar/1cee7d894de5bb1a95ed to your computer and use it in GitHub Desktop.
Save yousefamar/1cee7d894de5bb1a95ed to your computer and use it in GitHub Desktop.
A old python script that walks a directory and searches files for a specified term
import os
sTerm = raw_input("Search term: ")
for root, dirs, files in os.walk("."):
print root
for fname in files:
print " "+fname
with open(root+os.sep+fname) as f:
flines = f.readlines()
for i,line in enumerate(flines):
if sTerm in line:
print " "+"Line "+str((i+1))+": "+line
print ""
raw_input("Press enter to quit...")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment