sbase

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

grep.1 (2369B)


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