sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

grep.1 (2367B)


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