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