sbase

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

grep.1 (2411B)


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