find in files linux code example

Example 1: find text in folder

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

Example 2: linux find any file linux

#find a file and print with path
find . -print | grep -i *.txt

Example 3: 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 \;

Example 4: find in file linux

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

Example 5: linux find file

# syntax 
# find *</path/to/dir> '(' *<Filter-1> *<and/or-operator> *<filter-2> ')'

# example 
find . '(' -name "Test*.pm" -a ! -name 'Useless*' ')'

Example 6: how to search keyword in linux

grep -w phoenix *