commands
grep — select matching lines
Selects matching text lines. -F uses literal strings, -E uses ERE, -n reports line numbers. Normally 0 match, 1 no match, 2 error; -q can mask an error when a match is found. Example assumes a fresh search-transform lab fixture.
Formal Syntax & Structure
linux syntaxlinux
grep [OPTION]... PATTERN [FILE]...Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| -F | option | literal pattern |
| -E | option | extended regex |
| -n | option | line numbers |
| PATTERN | operand | search expression |
| FILE | operand | input file |
Return Value
exit status and output
Selects matching text lines. -F uses literal strings, -E uses ERE, -n reports line numbers. Normally 0 match, 1 no match, 2 error; -q can mask an error when a match is found.
Working Example
Example Snippetlinux
grep -nF 'ERROR' events.log