add info on mpcc; remove extraneous paragraph, minor cleanup
[unix-history] / usr / src / usr.bin / find / find.1
CommitLineData
3559318a
JL
1.\" Copyright (c) 1985 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)find.1 6.3 (Berkeley) %G%
910ee6b3 6.\"
17b268fb 7.TH FIND 1 ""
910ee6b3
KM
8.AT 3
9.SH NAME
10find \- find files
11.SH SYNOPSIS
12.B find
3559318a 13pathname-list expression
17b268fb
KM
14.br
15.B find
3559318a 16pattern
910ee6b3 17.SH DESCRIPTION
3559318a
JL
18In the first form above,
19.I find
910ee6b3
KM
20recursively descends
21the directory hierarchy for
22each pathname in the
23.I pathname-list
24(i.e., one or more pathnames)
25seeking files that match a boolean
26.I expression
27written in the primaries given below.
28In the descriptions, the argument
29.I n
30is used as a decimal integer
31where
32.I +n
33means more than
34.I n,
35.I \-n
36means less than
37.I n
38and
39.I n
40means exactly
41.IR n .
17b268fb 42.PP
3559318a
JL
43The second form rapidly searches a database for all pathnames
44which match
45.IR pattern .
46Usually the database is recomputed
47weekly and contains the pathnames
48of all files which are publicly accessible.
49If escaped, normal shell
50\*(lqglobbing\*(rq characters (`*', `?', `[', and ']')
51may be used in
52.IR pattern ,
53but the matching differs in that no characters
54.RI ( e.g. " `/')"
55have to be matched explicitly.
56As a special case, a simple
57.I pattern
58containing no globbing characters
59is matched as though it were
60.IR *pattern* ;
61if any globbing character appears
62there are no implicit globbing characters.
910ee6b3
KM
63.TP 10n
64.BR \-name " filename"
65True if the
66.I filename
67argument matches the current file name.
68Normal
3559318a 69shell
910ee6b3
KM
70argument syntax may be used if escaped (watch out for
71`[', `?' and `*').
72.TP
73.BR \-perm " onum"
74True if the file permission flags
75exactly
76match the
77octal number
78.I onum
79(see
80.IR chmod (1)).
81If
82.I onum
83is prefixed by a minus sign,
84more flag bits (017777, see
85.IR stat (2))
86become significant and
87the flags are compared:
88.IR (flags&onum)==onum .
89.TP
90.BR \-type " c"
91True if the type of the file
92is
93.I c,
94where
95.I c
96is
17b268fb 97.B "b, c, d, f, l"
910ee6b3 98or
17b268fb 99.B s
910ee6b3
KM
100for
101block special file, character special file,
17b268fb 102directory, plain file, symbolic link, or socket.
910ee6b3
KM
103.TP
104.BR \-links " n"
105True if the file has
106.I n
107links.
108.TP
109.BR \-user " uname"
110True if the file belongs to the user
111.I uname
112(login name or numeric user ID).
113.TP
239e9d73
S
114.B \-nouser
115True if the file belongs to a user
116.I not
117in the /etc/passwd database.
118.TP
910ee6b3
KM
119.BR \-group " gname"
120True if the file belongs to group
121.I gname
122(group name or numeric group ID).
123.TP
239e9d73
S
124.B \-nogroup
125True if the file belongs to a group
126.I not
127in the /etc/group database.
128.TP
910ee6b3
KM
129.BR \-size " n"
130True if the file is
131.I n
132blocks long (512 bytes per block).
133.TP
134.BR \-inum " n"
135True if the file has inode number
136.I n.
137.TP
138.BR \-atime " n"
139True if the file has been accessed in
140.I n
141days.
142.TP
143.BR \-mtime " n"
144True if the file has been modified in
145.I n
146days.
147.TP
148.BR \-exec " command"
149True if the executed command returns
150a zero value as exit status.
151The end of the command must be punctuated by an escaped
152semicolon.
153A command argument `{}' is replaced by the
154current pathname.
155.TP
156.BR \-ok " command"
157Like
158.B \-exec
159except that the generated command is written on
160the standard output, then the standard input is read
161and the command executed only upon response
162.BR y .
163.TP
164.B \-print
165Always true;
166causes the current pathname to be printed.
167.TP
239e9d73
S
168.B \-ls
169Always true;
170causes current pathname to be printed together
171with its associated statistics.
172These include (respectively) inode number,
173size in kilobytes (1024 bytes),
174protection mode,
175number of hard links,
176user,
177group,
178size in bytes,
179and modification time.
180If the file is a special file
181the size field will instead contain the major and minor
182device numbers.
183If the file is a symbolic link the
184pathname of the linked-to file is printed preceded by ``->''.
185The format is identical to that of ``ls -gilds''
186(note however that formatting is done internally,
187without executing the ls program).
188.TP
910ee6b3
KM
189.BR \-newer " file"
190True if
191the current file has been modified more recently than the argument
192.I file.
239e9d73 193.TP
3559318a
JL
194.BR \-cpio " file"
195Write the current file on the argument
196.I file
197in
198.I cpio
199format.
200.TP
239e9d73
S
201.B \-xdev
202Always true;
203causes find
204.I not
205to traverse down into a file system different
206from the one on which current
207.I argument
208pathname resides.
910ee6b3
KM
209.PP
210The primaries may be combined using the following operators
211(in order of decreasing precedence):
212.TP 4
2131)
214A parenthesized group of primaries and operators
215(parentheses are special to the Shell and must be escaped).
216.TP 4
2172)
218The negation of a primary
219(`!' is the unary
220.I not
221operator).
222.TP 4
2233)
224Concatenation of primaries
225(the
226.I and
227operation
228is implied by the juxtaposition of two primaries).
229.TP 4
2304)
231Alternation of primaries
232.RB "(`" \-o "' is the"
233.I or
234operator).
17b268fb
KM
235.SH EXAMPLES
236.PP
3559318a
JL
237To find all accessible files whose pathname contains `find':
238.IP
239find find
240.PP
241To typeset all variants of manual pages for `ls':
17b268fb
KM
242.IP
243vtroff -man `find '*man*/ls.?'`
244.PP
910ee6b3
KM
245To remove all files named
246`a.out' or `*.o' that have not been accessed for a week:
247.IP "" .2i
3559318a 248find / \e( \-name a.out \-o \-name '*.o' \e) \-atime +7 \-exec rm {} \e\;
910ee6b3 249.SH FILES
3559318a
JL
250.nf
251.ta \w'/usr/lib/find/find.codes 'u
910ee6b3 252/etc/passwd
910ee6b3 253/etc/group
3559318a
JL
254/usr/lib/find/find.codes coded pathnames database
255.fi
910ee6b3 256.SH "SEE ALSO"
5710a779 257sh(1), test(1), fs(5)
17b268fb
KM
258.br
259Relevant paper in February, 1983 issue of
260.I ;login:.
910ee6b3 261.SH BUGS
3559318a
JL
262The first form's syntax is painful, and
263the second form's exact semantics is confusing and
264can vary from site to site.
265.PP
266More than one `-newer' option does not work properly.