BSD 2 development
[unix-history] / man / grep.u
CommitLineData
d38390b9
BJ
1.TH GREP UCB 2/24/79 UCB
2.SH NAME
3grep \- search a file for a pattern
4.SH SYNOPSIS
5.B grep
6[
7.B \-v
8] [
9.B \-b
10] [
11.B \-c
12] [
13.B \-n
14] [
15.B \-l
16] [
17.B \-i
18] [
19.B \-w
20] expression [ file ] ...
21.SH DESCRIPTION
22.I Grep
23searches the input files
24(standard input default)
25for lines matching the
26regular expression.
27Normally, each line found
28is copied to the standard output.
29If the
30.B \-v
31flag is used,
32all lines but those matching
33are printed.
34If the
35.B \-c
36flag is used,
37only a count of matching lines is printed.
38If the
39.B \-l
40flag is used,
41only names of files which contain matching lines are printed.
42If the
43.B \-i
44flag is used, then case of letters is ignored in comparisons.
45If the
46.B \-w
47flag is used, then the expression is searched for as a word
48(as if surrounded by `\e<' and `\e>',
49see
50.IR ex (UCB))
51If the
52.B \-n
53flag is used,
54each line is preceded
55its relative line number in the file.
56If the
57.B \-b
58flag is used,
59each line is preceded by the block number
60on which it was found.
61This is sometimes useful in locating
62disk block numbers by context.
63.PP
64In all cases the file name is shown if there is more than one input file.
65.PP
66For a complete description
67of the regular expressions,
68see
69.IR ex (UCB).
70Care should be taken when
71using the characters
72$ * [ ^ | ( ) and \\ in the regular
73expression as they are
74also meaningful to the Shell.
75It is generally necessary to enclose the
76entire
77.I expression
78argument in quotes.
79.SH "SEE ALSO"
80ex(UCB)
81.SH BUGS
82Lines
83are limited to 256 characters;
84longer lines are truncated.