Grep is a handy command-line utility that enables you to search text or files.
More formally: Grep (Global Regular Expression Print) is a utility for searching plain-text datasets for lines that match a given regular expression.
Grep was developed for Unix, but is now available for all unix-like systems (e.g. Linux).
Basic Command Syntax
Ignore Case
Use -i:
Recursive Search
Use -r:
To suppress the filename. use the -h option. This example shows suppressed filenames and sends the result output to a file:
Search for Whole Words
Grep will return lines that contain the target string - it may be a fragment of another string. To return only lines containing the target string as a distinct word, use the -w option:
Search for many words requires egrep (extended grep), or escaping the pipe character: