How to search for a specific string contained in multiple files under a directory with grep

You may want to search for a specific character string from many files under a specific directory. In such cases, use the grep -r option.

grep -r String Directory1 (Directory2 ...)

This is an example of searching for files containing "Hello world" from the directories under lib and templates.

grep -r "Hello world" lib templates

Associated Information