grep prints lines that contain a match for a pattern within files.
grep can use regular expressions and has several options to improve the quality of the results.
-A
, -B
and -C
options are not available in POSIX (see the POSIX specifications for grep
).
fgrep stands for "Fixed-string Global Regular Expressions Print". fgrep is the same as grep -F
. This commands is a faster grep and behaves as grep but does NOT recognize any regular expression meta-characters as being special. The search will complete faster because it only processes a simple string rather than a complex pattern.
pgrep is an acronym that stands for "Process-ID Global Regular Expressions Print". pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria to stdout. pgrep is handy when all you want to know is the process id integer of a process.
grep | egrep(grep -E) | fgrep(grep -F) | pgrep |
---|---|---|---|
Basic Regular Expressions (BRE) | Extended Regular Expressions (ERE) | Searches only strings | Searches process by name |
For more information and reference use some of the following links:
What is the difference between grep, egrep and fgrep ? Unix&Linux StackExchange
Why does my regular expression work in X but not in Y? Unix&Linux StackExchange
What is the difference between grep, pgrep, egrep, fgrep? Superuser