find word in file linux code example

Example 1: bash find all files containing string

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

Example 2: linux find from file content

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

Example 3: find text pattern in file linux

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

Example 4: how to find a word in files linux

# this will search all subdirectories for text (no case sensitivity)
grep -inR "your text" .

Example 5: linux find file containing text

# syntax 
# find *</path/to/dir> -name '*<file(s)-to-search>' -exec grep '*<string-to-find>' {} /dev/null \;

# example
find 'C:/Users/JacquesK' -name '*.*' -exec grep 'Random text to find' {} /dev/null \;