Archives for the ‘Python’ Category

A simple python grep

Here’s a simplistic text search script that can be run quickly from a Windows command line or via your favorite editor (gvim). import os import sys if sys.argv[1] == ”: print “Usage: python grep.py searchterm pathtosearch” sys.exit() searchterm = sys.argv[1] pathtosearch = sys.argv[2] os.chdir(pathtosearch) for root,dir,files in os.walk(pathtosearch): for fi in files: path = os.path.join(root,fi) [...]