grep
| Function | Print lines that match a pattern, from a page body or from stdin (pipe). |
| Options | See table below. Options can be combined. |
| Limitations | A bare grep with no pattern/path and no pipe reports a missing operand. |
| Option | Meaning |
|---|---|
-i | Ignore case |
-v | Invert match (lines that do not match) |
-n | Prefix each line with its line number |
-c | Print a count of matching lines instead of the lines |
Matching lines are printed one per line.
Examples
Section titled “Examples”$ grep a ./page1$ grep -n pattern ./page1$ grep -c pattern ./page1$ ls | grep -i page$ ls | grep -v DraftSee help grep in the console for the same option list.