grep grep code example

Example 1: 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

Example 2: grep -i

With -i flag you can grep a substring with insensitive-case:
grep -i "substring_with_lower_or_upper_case"

Tags:

Misc Example