Next: , Previous: , Up: Command-line Options   [Contents][Index]


2.1.5 Context Line Control

Context lines are non-matching lines that are near a matching line. They are output only if one of the following options are used. Regardless of how these options are set, grep never outputs any given line more than once. If the -o (--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 -- between groups of lines.

--no-group-separator

When -A, -B or -C are in use, do not print a separator between groups of lines.

Here are some points about how grep chooses the separator to print between prefix fields and line content:


Next: , Previous: , Up: Command-line Options   [Contents][Index]