morpheus-base

morpheus base system
git clone git://git.2f30.org/morpheus-base
Log | Files | Refs

grep.1 (2292B)


      1 .Dd November 21, 2014
      2 .Dt GREP 1 sbase\-VERSION
      3 .Sh NAME
      4 .Nm grep
      5 .Nd search files for patterns
      6 .Sh SYNOPSIS
      7 .Nm grep
      8 .Op Fl EFHchilnqsvx
      9 .Op Fl e Ar pattern
     10 .Op Fl f Ar file
     11 .Op Ar pattern
     12 .Op Ar file ...
     13 .Sh DESCRIPTION
     14 .Nm
     15 searches the input files for lines that match the
     16 .Ar pattern ,
     17 a regular expression as defined in
     18 .Xr regex 7 .
     19 By default each matching line is printed to stdout.  If no file is given
     20 .Nm
     21 reads from stdin.
     22 .Sh OPTIONS
     23 .Bl -tag -width Ds
     24 .It Fl E
     25 Match using extended regex.
     26 .It Fl F
     27 Match using fixed strings.  Treat each pattern specified as a string instead of a regular
     28 expression.
     29 .It Fl H
     30 Prefix each matching line with its filename in the output. This is the
     31 default when there is more than one file specified.
     32 .It Fl c
     33 Print only a count of matching lines.
     34 .It Fl e Ar pattern
     35 Specify a pattern used during the search of the input: an input
     36 line is selected if it matches any of the specified patterns.
     37 This option is most useful when multiple -e options are used to
     38 specify multiple patterns, or when a pattern begins with a dash
     39 .It Fl f Ar file
     40 Read one or more patterns from the file named by the pathname file.
     41 Patterns in file shall be terminated by a <newline>. A null pattern can be
     42 specified by an empty line in pattern_file. Unless the -E or -F option is
     43 also specified, each pattern shall be treated as a BRE.
     44 (`-').
     45 .It Fl h
     46 Do not prefix each line with 'filename:' prefix.
     47 .It Fl i
     48 Match lines case insensitively.
     49 .It Fl l
     50 Print only the names of files with matching lines.
     51 .It Fl n
     52 Prefix each matching line with its line number in the input.
     53 .It Fl q
     54 Print nothing, only return status.
     55 .It Fl s
     56 Suppress the error messages ordinarily written for nonexistent or unreadable files.
     57 .It Fl v
     58 Select lines which do
     59 .B not
     60 Match the pattern.
     61 .It Fl x
     62 Consider only input lines that use all characters in the line excluding the terminating <newline> to
     63 match an entire fixed string or regular expression to be matching lines.
     64 .El
     65 .Sh EXIT STATUS
     66 .Bl -tag -width Ds
     67 .It 0
     68 One or more lines were matched.
     69 .It 1
     70 No lines were matched.
     71 .It > 1
     72 An error occurred.
     73 .El
     74 .Sh SEE ALSO
     75 .Xr regex 7 ,
     76 .Xr sed 1
     77 .Sh STANDARDS
     78 The
     79 .Nm
     80 utility is compliant with the
     81 .St -p1003.1-2008
     82 specification.
     83 .Pp
     84 The flags
     85 .Op Fl Hh
     86 are an extension to that specification.