what grep command does code example

Example 1: linux search for line in file

grep -R "keyword" /directory/

Example 2: find text pattern in file linux

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

Example 3: how to grep

grep 'word' filename
fgrep 'word-to-search' file.txt
grep 'word' file1 file2 file3
grep 'string1 string2'  filename
cat otherfile | grep 'something'
command | grep 'something'
command option1 | grep 'data'
grep --color 'data' fileName
grep [-options] pattern filename
fgrep [-options] words file