grep in files code example

Example 1: grep in all files

grep -rni "string" *

Example 2: bash find all files containing string

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

Example 3: linux search for line in file

grep -R "keyword" /directory/

Example 4: ubuntu grep text in files

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

Example 5: read string by string in file in linux

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

Example 6: how to search keyword in linux

grep -w phoenix *