To recursively search all files in a directory for ‘SearchText’ and print out matching files you can use the grep command with the ‘–files-with-matches / -l’ and ‘–recursive / -r’ flags. For example, to search the current directory (‘.’):
grep -rl "SearchText" .
Note, if you run this on a directory with lots of subdirectories (e.g., your home folder) it will take a long time to run.
You can specify to only include files matching a pattern using the ‘–include’ flag:
grep -rl --include "*py" "SearchText" .
or exclude files matching a pattern using the ‘–exclude’ flag.
grep -rl --exclude "*pyc" "SearchText" .