BSD 3 development
[unix-history] / usr / man / man1 / find.1
CommitLineData
e6817382
BJ
1.TH FIND 1
2.SH NAME
3find \- find files
4.SH SYNOPSIS
5.B find
6pathname-list expression
7.SH DESCRIPTION
8.I Find
9recursively descends
10the directory hierarchy for
11each pathname in the
12.I pathname-list
13(i.e., one or more pathnames)
14seeking files that match a boolean
15.I expression
16written in the primaries given below.
17In the descriptions, the argument
18.I n
19is used as a decimal integer
20where
21.I +n
22means more than
23.I n,
24.I \-n
25means less than
26.I n
27and
28.I n
29means exactly
30.IR n .
31.TP 10n
32.BR \-name " filename"
33True if the
34.I filename
35argument matches the current file name.
36Normal
37Shell
38argument syntax may be used if escaped (watch out for
39`[', `?' and `*').
40.TP
41.BR \-perm " onum"
42True if the file permission flags
43exactly
44match the
45octal number
46.I onum
47(see
48.IR chmod (1)).
49If
50.I onum
51is prefixed by a minus sign,
52more flag bits (017777, see
53.IR stat (2))
54become significant and
55the flags are compared:
56.IR (flags&onum)==onum .
57.TP
58.BR \-type " c"
59True if the type of the file
60is
61.I c,
62where
63.I c
64is
65.B "b, c, d"
66or
67.B f
68for
69block special file, character special file,
70directory or plain file.
71.TP
72.BR \-links " n"
73True if the file has
74.I n
75links.
76.TP
77.BR \-user " uname"
78True if the file belongs to the user
79.I uname
80(login name or numeric user ID).
81.TP
82.BR \-group " gname"
83True if the file belongs to group
84.I gname
85(group name or numeric group ID).
86.TP
87.BR \-size " n"
88True if the file is
89.I n
90blocks long (512 bytes per block).
91.TP
92.BR \-inum " n"
93True if the file has inode number
94.I n.
95.TP
96.BR \-atime " n"
97True if the file has been accessed in
98.I n
99days.
100.TP
101.BR \-mtime " n"
102True if the file has been modified in
103.I n
104days.
105.TP
106.BR \-exec " command"
107True if the executed command returns
108a zero value as exit status.
109The end of the command must be punctuated by an escaped
110semicolon.
111A command argument `{}' is replaced by the
112current pathname.
113.TP
114.BR \-ok " command"
115Like
116.B \-exec
117except that the generated command is written on
118the standard output, then the standard input is read
119and the command executed only upon response
120.BR y .
121.TP
122.B \-print
123Always true;
124causes the current pathname to be printed.
125.TP
126.BR \-newer " file"
127True if
128the current file has been modified more recently than the argument
129.I file.
130.PP
131The primaries may be combined using the following operators
132(in order of decreasing precedence):
133.TP 4
1341)
135A parenthesized group of primaries and operators
136(parentheses are special to the Shell and must be escaped).
137.TP 4
1382)
139The negation of a primary
140(`!' is the unary
141.I not
142operator).
143.TP 4
1443)
145Concatenation of primaries
146(the
147.I and
148operation
149is implied by the juxtaposition of two primaries).
150.TP 4
1514)
152Alternation of primaries
153.RB "(`" \-o "' is the"
154.I or
155operator).
156.SH EXAMPLE
157To remove all files named
158`a.out' or `*.o' that have not been accessed for a week:
159.IP "" .2i
160find / \\( \-name a.out \-o \-name '*.o' \\)
161\-atime +7 \-exec rm {} \\;
162.SH FILES
163/etc/passwd
164.br
165/etc/group
166.SH "SEE ALSO"
167sh(1), test(1), filsys(5)
168.SH BUGS
169The syntax is painful.