Here’s an example of how to do a recursive grep through your file system. In this case I’m looking for the text ‘otalo.AO.models’ in all Python scripts (*.py).
It turns out that the find command is way to do this. It lets you execute another command on its results. So here we pass the results to grep. The -H grep param is needed to get the file names to print in front the actual content.
So the general form is:
sudo find / -name [search string] -exec [any command] {} \;
And my example search is:
sudo find / -name *.py -exec grep -H 'otalo.AO.models' {} \;
which happily gives this result:
/home/otalo/otalo/AO/fixtures/seed_data.py:from otalo.AO.models import User, Forum, Tag, Admin, Line
/opt/freeswitch/scripts/AO/experiment-digest.py:from otalo.AO.models import Line, Message_forum
. . .
