[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
2.1.5 Context Line Control
Regardless of how these options are set,
grep
will never print any given line more than once.
If the ‘-o’ or ‘--only-matching’ option is specified,
these options have no effect and a warning is given upon their use.
- ‘-A num’
- ‘--after-context=num’
-
Print num lines of trailing context after matching lines.
- ‘-B num’
- ‘--before-context=num’
-
Print num lines of leading context before matching lines.
- ‘-C num’
- ‘-num’
- ‘--context=num’
-
Print num lines of leading and trailing output context.
- ‘--group-separator=string’
-
When ‘-A’, ‘-B’ or ‘-C’ are in use, print string instead of ‘--’ around disjoint groups of lines.
- ‘--no-group-separator’
-
When ‘-A’, ‘-B’ or ‘-C’ are in use, print disjoint groups of lines adjacent to each other.
Matching lines normally use ‘:’ as a separator between prefix fields and actual line content. Context (i.e., non-matching) lines use ‘-’ instead. When no context is specified, matching lines are simply output one right after another. When nonzero context is specified, lines that are adjacent in the input form a group and are output one right after another, while a separator appears by default between disjoint groups on a line of its own and without any prefix. The default separator is ‘--’, however whether to include it and its appearance can be changed with the options above. Each group may contain several matching lines when they are close enough to each other that two otherwise adjacent but divided groups connect and can just merge into a single contiguous one.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |