Option 'Y' --> Output Context Lines Before Match. Normally QTGrep only outputs the line matched. However, sometimes it is desirable to view the matched lines within the context of the lines before and after the matched line. This option turns on and off or sets the number of lines output before the matched line. The format of this option is:

-Y+ --> turns on outputting context lines before the matched line - uses
        the value for the number of lines as set in the configuration
        file.
-Y- --> turns off outputting of context lines before the matched line.

-Ynn
or
-Y(nn)
or
-Y nn
   --> this form turns on outputting context lines after the match line
       and sets the number of lines output to 'nn'

Note that when context lines are output before and/or after matched lines, the context lines are distingished from the matched lines by prefixing each context line with a single hyphen, '-', and prefixing each match line with a single colon, ':'. Thus the output for context lines following a match line is:

-This line is the first context line before
-This line is the second context line before
:This line matched an input expression
-This line is the first context line following
-This line is the second context line following

Note that if expression numbers are also output, the expression number is output as a field of asterics, '*', for context lines.

Note that if line/record numbers are also output, the record number of the context line is output also. As mentioned above, the record number specifier, 'R', is followed by a hyphen, '-', for context lines and by a colon, ':', for match lines.

Thus if record number are output, the output would resemble:

   343- This line is the first context line before
   344- This line is the second context line before
   345: This line matched an input expression
   346- This line is the first context line following
   347- This line is the second context line following

Note: A numeric value set with this option over-rides any numeric value set with the 'O' option.

See Also: -?A and -?O

This is a local option and may be turned on or off for separate files as desired.

The corresponding long option is: --before-context=[on|off|NUM]

If context lines are turned on with the long option:

--before-context=on

Then the number of context lines specified in the configuration file is utilized. If no value was specified in the configuration file, then the
default value of 5 is utilized.

Incompatible Options Are:
Z
File  Preview
c
Count of Matches Only
r
Match Replacement
y
Ignore Records
z
Simulate Match Replacement


© Terry D. Boldt 1997-2005
All Rights Reserved
Last Updated: Nov. 24, 2005