Searching for strings in files along with using os.walk
<p>I have written a Python Script to find out lines containing a particular script from each of the files within a directory. It works fine if i make this script run in the directory having those files.  </p>

<pre><code>#!/usr/bin/env python
import os

def searchthis(location, searchterm):
    for fname in os.listdir(location):
        fullpath = os.path.join(location, fname)
        for line in file(fullpath):
            if searchterm in line:
                print line



searchthis(os.getcwd(), "mystring")
</code></pre>

<p>Is there any way I could do this with <code>os.walk</code> and search for recursively in each of the files present in all the directories as well as subdirectories. </p>
