Last Updated: February 25, 2016
·
1.057K
· goldstift

Shell: grep in specific files in a subfolder

If you need to search textual occurrences of a pattern in files inside of a specific subfolder, the following command might come in handy for you:

find . -path './folder-prefix-*/target/*.java' -exec grep -iHn "search pattern" {} \;

This will find files matching the specific "-path" pattern and greps the resulting files for occurrences of "search pattern" ignoring case.

See the man pages for find and grep for more details.