Print this page
4701 would like grep context options (-A, -B, -C)


  33     [\fB-bHhinsvwx\fR] [\fB-e\fR \fIpattern_list\fR]... \fB-f\fR \fIpattern_file\fR...
  34     [\fIfile\fR]...
  35 .fi
  36 
  37 .LP
  38 .nf
  39 \fB/usr/xpg4/bin/grep\fR [\fB-E\fR | \fB-F\fR] [\fB-c\fR | \fB-l\fR | \fB-q\fR] [\fB-r\fR | \fB-R\fR]
  40     [\fB-bHhinsvwx\fR] \fIpattern\fR [\fIfile\fR]...
  41 .fi
  42 
  43 .SH DESCRIPTION
  44 .sp
  45 .LP
  46 The \fBgrep\fR utility searches text files for a pattern and prints all lines
  47 that contain that pattern.  It uses a compact non-deterministic algorithm.
  48 .sp
  49 .LP
  50 Be careful using the characters \fB$\fR, \fB*\fR, \fB[\fR, \fB^\fR, \fB|\fR,
  51 \fB(\fR, \fB)\fR, and \fB\e\fR in the \fIpattern_list\fR because they are also
  52 meaningful to the shell. It is safest to enclose the entire \fIpattern_list\fR
  53 in single quotes \fBa\'\fR\&...\fBa\'\fR\&.
  54 .sp
  55 .LP
  56 If no files are specified, \fBgrep\fR assumes standard input. Normally, each
  57 line found is copied to standard output. The file name is printed before each
  58 line found if there is more than one input file.
  59 .SS "/usr/bin/grep"
  60 .sp
  61 .LP
  62 The \fB/usr/bin/grep\fR utility uses limited regular expressions like those
  63 described on the \fBregexp\fR(5) manual page to match the patterns.
  64 .SS "/usr/xpg4/bin/grep"
  65 .sp
  66 .LP
  67 The options \fB-E\fR and \fB-F\fR affect the way \fB/usr/xpg4/bin/grep\fR
  68 interprets \fIpattern_list\fR. If \fB-E\fR is specified,
  69 \fB/usr/xpg4/bin/grep\fR interprets \fIpattern_list\fR as a full regular
  70 expression (see \fB-E\fR for description).  If \fB-F\fR is specified,
  71 \fBgrep\fR interprets \fIpattern_list\fR as a fixed string. If neither are
  72 specified, \fBgrep\fR interprets \fIpattern_list\fR as a basic regular
  73 expression as described on \fBregex\fR(5) manual page.


 190 .RS 6n
 191 Prints all lines except those that contain the pattern.
 192 .RE
 193 
 194 .sp
 195 .ne 2
 196 .na
 197 \fB\fB-w\fR\fR
 198 .ad
 199 .RS 6n
 200 Searches for the expression as a word as if surrounded by \fB\e<\fR and
 201 \fB\e>\fR\&.
 202 .RE
 203 
 204 .SS "/usr/xpg4/bin/grep"
 205 .sp
 206 .LP
 207 The following options are supported for \fB/usr/xpg4/bin/grep\fR only:
 208 .sp
 209 .ne 2






































 210 .na
 211 \fB\fB-e\fR \fIpattern_list\fR\fR
 212 .ad
 213 .RS 19n
 214 Specifies one or more patterns to be used during the search for input. Patterns
 215 in \fIpattern_list\fR must be separated by a NEWLINE character. A null pattern
 216 can be specified by two adjacent newline characters in \fIpattern_list\fR.
 217 Unless the \fB-E\fR or \fB-F\fR option is also specified, each pattern is
 218 treated as a basic regular expression.  Multiple \fB-e\fR and \fB-f\fR options
 219 are accepted by \fBgrep\fR. All of the specified patterns are used when
 220 matching lines, but the order of evaluation is unspecified.
 221 .RE
 222 
 223 .sp
 224 .ne 2
 225 .na
 226 \fB\fB-E\fR\fR
 227 .ad
 228 .RS 19n
 229 Matches using full regular expressions. Treats each pattern specified as a full




  33     [\fB-bHhinsvwx\fR] [\fB-e\fR \fIpattern_list\fR]... \fB-f\fR \fIpattern_file\fR...
  34     [\fIfile\fR]...
  35 .fi
  36 
  37 .LP
  38 .nf
  39 \fB/usr/xpg4/bin/grep\fR [\fB-E\fR | \fB-F\fR] [\fB-c\fR | \fB-l\fR | \fB-q\fR] [\fB-r\fR | \fB-R\fR]
  40     [\fB-bHhinsvwx\fR] \fIpattern\fR [\fIfile\fR]...
  41 .fi
  42 
  43 .SH DESCRIPTION
  44 .sp
  45 .LP
  46 The \fBgrep\fR utility searches text files for a pattern and prints all lines
  47 that contain that pattern.  It uses a compact non-deterministic algorithm.
  48 .sp
  49 .LP
  50 Be careful using the characters \fB$\fR, \fB*\fR, \fB[\fR, \fB^\fR, \fB|\fR,
  51 \fB(\fR, \fB)\fR, and \fB\e\fR in the \fIpattern_list\fR because they are also
  52 meaningful to the shell. It is safest to enclose the entire \fIpattern_list\fR
  53 in single quotes \fB\'\fR\&...\fB\'\fR\&.
  54 .sp
  55 .LP
  56 If no files are specified, \fBgrep\fR assumes standard input. Normally, each
  57 line found is copied to standard output. The file name is printed before each
  58 line found if there is more than one input file.
  59 .SS "/usr/bin/grep"
  60 .sp
  61 .LP
  62 The \fB/usr/bin/grep\fR utility uses limited regular expressions like those
  63 described on the \fBregexp\fR(5) manual page to match the patterns.
  64 .SS "/usr/xpg4/bin/grep"
  65 .sp
  66 .LP
  67 The options \fB-E\fR and \fB-F\fR affect the way \fB/usr/xpg4/bin/grep\fR
  68 interprets \fIpattern_list\fR. If \fB-E\fR is specified,
  69 \fB/usr/xpg4/bin/grep\fR interprets \fIpattern_list\fR as a full regular
  70 expression (see \fB-E\fR for description).  If \fB-F\fR is specified,
  71 \fBgrep\fR interprets \fIpattern_list\fR as a fixed string. If neither are
  72 specified, \fBgrep\fR interprets \fIpattern_list\fR as a basic regular
  73 expression as described on \fBregex\fR(5) manual page.


 190 .RS 6n
 191 Prints all lines except those that contain the pattern.
 192 .RE
 193 
 194 .sp
 195 .ne 2
 196 .na
 197 \fB\fB-w\fR\fR
 198 .ad
 199 .RS 6n
 200 Searches for the expression as a word as if surrounded by \fB\e<\fR and
 201 \fB\e>\fR\&.
 202 .RE
 203 
 204 .SS "/usr/xpg4/bin/grep"
 205 .sp
 206 .LP
 207 The following options are supported for \fB/usr/xpg4/bin/grep\fR only:
 208 .sp
 209 .ne 2
 210 .na
 211 \fB\fB-A\fR \fInumber\fR\fR
 212 .ad
 213 .RS 19n
 214 Prints \fInumber\fR input lines of context after each matching line. If there
 215 are multiple matching lines, their context lines are separated by a \fB--\fR
 216 delimiter line.
 217 .RE
 218 
 219 .sp
 220 .ne 2
 221 .na
 222 \fB\fB-B\fR \fInumber\fR\fR
 223 .ad
 224 .RS 19n
 225 Prints \fInumber\fR input lines of context before each matching line. If there
 226 are multiple matching lines, their context lines are separated by a \fB--\fR
 227 delimiter line.
 228 .RE
 229 
 230 .sp
 231 .ne 2
 232 .na
 233 \fB\fB-\fR\fInumber\fR\fR
 234 .ad
 235 .br
 236 .na
 237 \fB\fB-C\fR \fInumber\fR\fR
 238 .ad
 239 .RS 19n
 240 Prints \fInumber\fR input lines of context before and \fInumber\fR input lines
 241 of context after each matching line. If there are multiple matching lines,
 242 their context lines are separated by a \fB--\fR delimiter line.
 243 .RE
 244 
 245 
 246 .sp
 247 .ne 2
 248 .na
 249 \fB\fB-e\fR \fIpattern_list\fR\fR
 250 .ad
 251 .RS 19n
 252 Specifies one or more patterns to be used during the search for input. Patterns
 253 in \fIpattern_list\fR must be separated by a NEWLINE character. A null pattern
 254 can be specified by two adjacent newline characters in \fIpattern_list\fR.
 255 Unless the \fB-E\fR or \fB-F\fR option is also specified, each pattern is
 256 treated as a basic regular expression.  Multiple \fB-e\fR and \fB-f\fR options
 257 are accepted by \fBgrep\fR. All of the specified patterns are used when
 258 matching lines, but the order of evaluation is unspecified.
 259 .RE
 260 
 261 .sp
 262 .ne 2
 263 .na
 264 \fB\fB-E\fR\fR
 265 .ad
 266 .RS 19n
 267 Matches using full regular expressions. Treats each pattern specified as a full