A friend of mine needed to check a directory full of text files, created as a log, for a specific string of text. I wrote him up a python script.
_________________________________________________________________________________# SEARCHES TEXT FILES IN THE CURRENT DIRECTORY. NOT RECURSIVE (diving into other directories within current directory).# place a one line string inside the quotes in below variable to search forsearch = "example"# once done searching, program will crash. 2lazy4errorhandlingimport osn = 0list = os.listdir(./")while True:active = open(list[n])for line in active:if line.count(search) != 0:print list[n]n += 1