linux find all files containing string code example

Example 1: bash find all files containing string

grep -r '/path/to/somewhere/' -e 'pattern'

Example 2: linux search for a given string in all files recursively

$ grep -r "String to be searched goes here" *

Example 3: ubuntu grep text in files

grep -r "mydomain.com" /etc/apache2/

Example 4: command line how to find all files that have a string

grep -rnw '/path/to/somewhere/' -e 'pattern'

Example 5: linux find all files name containing string

find . -name "*ABC*" -exec grep -H 'XYZ' {} +