pythongrepplonezope

How do you grep through code that lives in many different directories?


I'm working on a Python program that makes heavy use of eggs (Plone). That means there are 198 directories full of Python code I might want to search through while debugging. Is there a good way to search only the .py files in only those directories, avoiding unrelated code and large binary files?


Solution

  • find DIRECTORY -name "*.py" | xargs grep PATTERN
    

    By the way, since writing this, I have discovered ack, which is a much better solution.

    (And since that edit, I have discovered ag).