/
rgrep.1.in
147 lines (147 loc) · 3.37 KB
/
rgrep.1.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
.\"
.\" %A%
.\"
.Dd September 17, 2007
.Dt RGREP 1
.Os MASTODON
.Sh NAME
.Nm rgrep
.Nd recursive grep
.Sh SYNOPSIS
.Nm
.Op Ar flags
.Ar pattern
.Ar path ...
.Sh DESCRIPTION
.Nm
recursively searches files in the named paths (or searches stdin if
no arguments are given) for lines containing the given
.Ar pattern .
.Pp
Like the more-traditional grep, it has many options that change
how it works, but many of these options are subtly different:
.Bl -tag -width Fl
.It Li -c
Count matches; don't print the lines that contain the patterns,
just the matches.
.It Li -e
Use POSIX-style regular expressions.
.It Li -h
When displaying lines that matches, highlight the text that matches the pattern.
.It Li -H
Don't display lines that match the pattern, display the text
that matches the pattern.
.It Li -i
Ignore case.
.It Li -l
Print the name of each file that contains a the pattern.
.It Li -n
As well as the line, print the line number of each line
that matches the pattern.
.It Li -F
Follow links.
.It Li -r
Recursively scan through directories (this is the default.)
.It Li -N
Don't recurse. This makes
.Nm
into a somewhat clumsy superslow grep.
.It Li -R Ar pat
Search only filenames that match
.Ar pat .
.It Li -v
Print (count) only lines that do NOT contain the pattern.
.It Li -x Ar pat
Search only filenames that have the extension
.Ar pat .
.It Li -D
Instead of searching, just print the names of the directories that
would be searched. (This makes
.Nm
into a somewhat slower version of
.Xr find 1 )
.It Li -W Ar len
Input files contain fixed-length records
.Ar len
characters long.
.El
The regular expression format that
.Nm
uses is a slightly extended version of the "basic" regular expressions
used in Henry Spencer's regex library. Regular expressions are made
up of plain text, plus the following special characters:
.Bl -tag -width Fl
.It Li \.
Match any single character except newlines.
.It Li \e Ns d
Match any digit.
.It Li \e Ns e
Match the ESCAPE character.
.It Li *
Match zero or more of the previous RE.
.It Li +
Match one or more of the previous RE.
.It Li ?
Match zero or one of the previous RE.
.It Li ^
Match beginning of line.
.It Li $
Match end of line.
.It Li [ Ns Ar ... Ns Li ]
Matches any single character between the brackets. As special cases,
a leading
.Li ^
means match everything EXCEPT the characters between the branches,
and a
.Li -
between two characters means to match any character between those
two (so
.Ar [a-z]
would mean to match any lowercase character, and
.Ar [0-9]
would match any single digit.
.It Li \e Ns <
Match the beginning of a word.
.It Li \e Ns >
Match the end of a word.
.It Li \e{ Ar num Li \e}
Match
.Ar num
instances of the previous RE.
.It Li \e( Ar RE Li \e)
Match RE as a subexpression.
.It Li \e Ns Ar <digit>
Match what was matched by the <digit>'th \e Ns ( RE \e Ns ) subexpression.
.El
.Sh BUGS
1. The
.Li \e Ns d
metacharacter is not implemented.
.br
2. The
.Li \e{ Ar ... Li \e}
command is not fully implemented.
.Sh AUTHOR
David Parsons (<orc@pell.portland.or.us>)
.br
The regular expression code is Henry Spencer's regex code (modified to support
.Ar \e< ,
.Ar \e> ,
.Ar \ee ,
.Ar ? ,
and
.Ar + Ns \.)
.Sh COPYRIGHT
.Nm
is Copyright 2007 by David Parsons.
.br
The regex library is Copyright 1992, 1993, 1994, 1997 Henry Spencer.
.Sh SEE ALSO
.Xr grep 1 ,
.Xr re_format 7
.Sh HISTORY
A version of the
.Nm
command is distributed with John Davis's
.Xr jed 8
editor.