Find specific text in files recursively

Written by Peter Davies on .

This is a simple one for finding specific text within multiple files:

find ./ -type f -name '*.p*' -exec grep -s *115 {} \; -print

or to a file:

find ./ -type f -name '*.php' -exec grep -s VAT {} \; -print > ~/output.txt

Very useful!

UPDATE

The exec grep command had some flaws, so the same can be achieved using:

find ./ -name "*.php" -print0 -type f | xargs -0 grep "addExpressionAttributeToSelect"