grep find text in files linux code example

Example 1: grep in all files

grep -rni "string" *

Example 2: find text in any file linux

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

Example 3: ubuntu grep text in files

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

Example 4: grep search for string in directory

grep -nr 'yourString*' .

Example 5: find text in linux file

grep 'word' filename
grep 'word' file1 file2 file3
grep 'string1 string2'  filename
cat otherfile | grep 'something'
command | grep 'something'
command option1 | grep 'data'
grep --color 'data' fileName