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