]>
Commit | Line | Data |
---|---|---|
e1a085ba | 1 | .\" Copyright (c) 1990, 1993 |
44bd5ea7 A |
2 | .\" The Regents of the University of California. All rights reserved. |
3 | .\" | |
4 | .\" This code is derived from software contributed to Berkeley by | |
5 | .\" the Institute of Electrical and Electronics Engineers, Inc. | |
6 | .\" | |
7 | .\" Redistribution and use in source and binary forms, with or without | |
8 | .\" modification, are permitted provided that the following conditions | |
9 | .\" are met: | |
10 | .\" 1. Redistributions of source code must retain the above copyright | |
11 | .\" notice, this list of conditions and the following disclaimer. | |
12 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer in the | |
14 | .\" documentation and/or other materials provided with the distribution. | |
15 | .\" 3. All advertising materials mentioning features or use of this software | |
16 | .\" must display the following acknowledgement: | |
17 | .\" This product includes software developed by the University of | |
18 | .\" California, Berkeley and its contributors. | |
19 | .\" 4. Neither the name of the University nor the names of its contributors | |
20 | .\" may be used to endorse or promote products derived from this software | |
21 | .\" without specific prior written permission. | |
22 | .\" | |
23 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
24 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
25 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
26 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
27 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
28 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
29 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
30 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
31 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
32 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
33 | .\" SUCH DAMAGE. | |
34 | .\" | |
c0fcf4e1 | 35 | .\" @(#)find.1 8.7 (Berkeley) 5/9/95 |
f14763b6 | 36 | .\" $FreeBSD: src/usr.bin/find/find.1,v 1.87 2009/09/20 16:47:56 jilles Exp $ |
44bd5ea7 | 37 | .\" |
ddb4a88b | 38 | .Dd February 24, 2008 |
44bd5ea7 A |
39 | .Dt FIND 1 |
40 | .Os | |
41 | .Sh NAME | |
42 | .Nm find | |
43 | .Nd walk a file hierarchy | |
44 | .Sh SYNOPSIS | |
c0fcf4e1 | 45 | .Nm |
44bd5ea7 | 46 | .Op Fl H | Fl L | Fl P |
c0fcf4e1 | 47 | .Op Fl EXdsx |
ddb4a88b A |
48 | .Op Fl f Ar path |
49 | .Ar path ... | |
50 | .Op Ar expression | |
e1a085ba A |
51 | .Nm |
52 | .Op Fl H | Fl L | Fl P | |
53 | .Op Fl EXdsx | |
ddb4a88b A |
54 | .Fl f Ar path |
55 | .Op Ar path ... | |
56 | .Op Ar expression | |
44bd5ea7 | 57 | .Sh DESCRIPTION |
e1a085ba A |
58 | The |
59 | .Nm | |
60 | utility recursively descends the directory tree for each | |
ddb4a88b | 61 | .Ar path |
44bd5ea7 A |
62 | listed, evaluating an |
63 | .Ar expression | |
c0fcf4e1 A |
64 | (composed of the |
65 | .Dq primaries | |
66 | and | |
67 | .Dq operands | |
68 | listed below) in terms | |
44bd5ea7 A |
69 | of each file in the tree. |
70 | .Pp | |
71 | The options are as follows: | |
c0fcf4e1 A |
72 | .Bl -tag -width indent |
73 | .It Fl E | |
74 | Interpret regular expressions followed by | |
75 | .Ic -regex | |
76 | and | |
77 | .Ic -iregex | |
ddb4a88b | 78 | primaries as extended (modern) regular expressions rather than basic |
c0fcf4e1 A |
79 | regular expressions (BRE's). |
80 | The | |
81 | .Xr re_format 7 | |
82 | manual page fully describes both formats. | |
44bd5ea7 | 83 | .It Fl H |
e1a085ba | 84 | Cause the file information and file type (see |
c0fcf4e1 A |
85 | .Xr stat 2 ) |
86 | returned for each symbolic link specified on the command line to be | |
44bd5ea7 A |
87 | those of the file referenced by the link, not the link itself. |
88 | If the referenced file does not exist, the file information and type will | |
c0fcf4e1 A |
89 | be for the link itself. |
90 | File information of all symbolic links not on | |
44bd5ea7 A |
91 | the command line is that of the link itself. |
92 | .It Fl L | |
e1a085ba | 93 | Cause the file information and file type (see |
c0fcf4e1 | 94 | .Xr stat 2 ) |
44bd5ea7 A |
95 | returned for each symbolic link to be those of the file referenced by the |
96 | link, not the link itself. | |
97 | If the referenced file does not exist, the file information and type will | |
98 | be for the link itself. | |
e1a085ba A |
99 | .Pp |
100 | This option is equivalent to the deprecated | |
101 | .Ic -follow | |
102 | primary. | |
44bd5ea7 | 103 | .It Fl P |
e1a085ba | 104 | Cause the file information and file type (see |
c0fcf4e1 | 105 | .Xr stat 2 ) |
44bd5ea7 | 106 | returned for each symbolic link to be those of the link itself. |
c0fcf4e1 | 107 | This is the default. |
44bd5ea7 | 108 | .It Fl X |
e1a085ba | 109 | Permit |
44bd5ea7 A |
110 | .Nm |
111 | to be safely used in conjunction with | |
112 | .Xr xargs 1 . | |
113 | If a file name contains any of the delimiting characters used by | |
c0fcf4e1 | 114 | .Xr xargs 1 , |
44bd5ea7 A |
115 | a diagnostic message is displayed on standard error, and the file |
116 | is skipped. | |
c0fcf4e1 A |
117 | The delimiting characters include single |
118 | .Pq Dq Li " ' " | |
119 | and double | |
120 | .Pq Dq Li " \*q " | |
121 | quotes, backslash | |
122 | .Pq Dq Li \e , | |
123 | space, tab and newline characters. | |
e1a085ba A |
124 | .Pp |
125 | However, you may wish to consider the | |
126 | .Fl print0 | |
127 | primary in conjunction with | |
128 | .Dq Nm xargs Fl 0 | |
129 | as an effective alternative. | |
44bd5ea7 | 130 | .It Fl d |
e1a085ba | 131 | Cause |
44bd5ea7 | 132 | .Nm |
e1a085ba A |
133 | to perform a depth-first traversal, i.e., directories |
134 | are visited in post-order and all entries in a directory will be acted | |
44bd5ea7 A |
135 | on before the directory itself. |
136 | By default, | |
137 | .Nm | |
e1a085ba | 138 | visits directories in pre-order, i.e., before their contents. |
44bd5ea7 | 139 | Note, the default is |
c0fcf4e1 | 140 | .Em not |
e1a085ba A |
141 | a breadth-first traversal. |
142 | .Pp | |
143 | This option is equivalent to the | |
144 | .Ic -depth | |
145 | primary of | |
146 | .St -p1003.1-2001 . | |
ddb4a88b | 147 | The |
e1a085ba | 148 | .Fl d |
ddb4a88b | 149 | option |
e1a085ba A |
150 | can be useful when |
151 | .Nm | |
152 | is used with | |
153 | .Xr cpio 1 | |
154 | to process files that are contained in directories with unusual permissions. | |
155 | It ensures that you have write permission while you are placing files in a | |
156 | directory, then sets the directory's permissions as the last thing. | |
44bd5ea7 | 157 | .It Fl f |
e1a085ba | 158 | Specify a file hierarchy for |
44bd5ea7 A |
159 | .Nm |
160 | to traverse. | |
161 | File hierarchies may also be specified as the operands immediately | |
162 | following the options. | |
c0fcf4e1 | 163 | .It Fl s |
e1a085ba | 164 | Cause |
c0fcf4e1 A |
165 | .Nm |
166 | to traverse the file hierarchies in lexicographical order, | |
167 | i.e., alphabetical order within each directory. | |
168 | Note: | |
169 | .Ql find -s | |
170 | and | |
171 | .Ql "find | sort" | |
172 | may give different results. | |
44bd5ea7 | 173 | .It Fl x |
e1a085ba | 174 | Prevent |
44bd5ea7 A |
175 | .Nm |
176 | from descending into directories that have a device number different | |
177 | than that of the file from which the descent began. | |
e1a085ba A |
178 | .Pp |
179 | This option is equivalent to the deprecated | |
180 | .Ic -xdev | |
181 | primary. | |
44bd5ea7 A |
182 | .El |
183 | .Sh PRIMARIES | |
c0fcf4e1 | 184 | .Bl -tag -width indent |
e1a085ba A |
185 | .It Ic -Bmin Ar n |
186 | True if the difference between the time of a file's inode creation | |
187 | and the time | |
188 | .Nm | |
189 | was started, rounded up to the next full minute, is | |
190 | .Ar n | |
191 | minutes. | |
192 | .It Ic -Bnewer Ar file | |
193 | Same as | |
194 | .Ic -newerBm . | |
195 | .It Ic -Btime Ar n Ns Op Cm smhdw | |
196 | If no units are specified, this primary evaluates to | |
197 | true if the difference between the time of a file's inode creation | |
198 | and the time | |
199 | .Nm | |
200 | was started, rounded up to the next full 24-hour period, is | |
201 | .Ar n | |
202 | 24-hour periods. | |
203 | .Pp | |
204 | If units are specified, this primary evaluates to | |
205 | true if the difference between the time of a file's inode creation | |
206 | and the time | |
207 | .Nm | |
208 | was started is exactly | |
209 | .Ar n | |
210 | units. | |
211 | Please refer to the | |
212 | .Ic -atime | |
213 | primary description for information on supported time units. | |
f14763b6 A |
214 | .It Ic -acl |
215 | May be used in conjunction with other primaries to locate | |
216 | files with extended ACLs. | |
217 | See | |
218 | .Xr acl 3 | |
219 | for more information. | |
c0fcf4e1 A |
220 | .It Ic -amin Ar n |
221 | True if the difference between the file last access time and the time | |
222 | .Nm | |
223 | was started, rounded up to the next full minute, is | |
224 | .Ar n | |
225 | minutes. | |
226 | .It Ic -anewer Ar file | |
227 | Same as | |
228 | .Ic -neweram . | |
e1a085ba A |
229 | .It Ic -atime Ar n Ns Op Cm smhdw |
230 | If no units are specified, this primary evaluates to | |
231 | true if the difference between the file last access time and the time | |
232 | .Nm | |
233 | was started, rounded up to the next full 24-hour period, is | |
234 | .Ar n | |
235 | 24-hour periods. | |
236 | .Pp | |
237 | If units are specified, this primary evaluates to | |
238 | true if the difference between the file last access time and the time | |
44bd5ea7 | 239 | .Nm |
e1a085ba | 240 | was started is exactly |
44bd5ea7 | 241 | .Ar n |
e1a085ba A |
242 | units. |
243 | Possible time units are as follows: | |
244 | .Pp | |
245 | .Bl -tag -width indent -compact | |
246 | .It Cm s | |
247 | second | |
248 | .It Cm m | |
249 | minute (60 seconds) | |
250 | .It Cm h | |
251 | hour (60 minutes) | |
252 | .It Cm d | |
253 | day (24 hours) | |
254 | .It Cm w | |
255 | week (7 days) | |
256 | .El | |
257 | .Pp | |
258 | Any number of units may be combined in one | |
259 | .Ic -atime | |
260 | argument, for example, | |
261 | .Dq Li "-atime -1h30m" . | |
262 | Units are probably only useful when used in conjunction with the | |
263 | .Cm + | |
264 | or | |
265 | .Cm - | |
266 | modifier. | |
c0fcf4e1 A |
267 | .It Ic -cmin Ar n |
268 | True if the difference between the time of last change of file status | |
269 | information and the time | |
270 | .Nm | |
271 | was started, rounded up to the next full minute, is | |
272 | .Ar n | |
273 | minutes. | |
274 | .It Ic -cnewer Ar file | |
275 | Same as | |
276 | .Ic -newercm . | |
e1a085ba A |
277 | .It Ic -ctime Ar n Ns Op Cm smhdw |
278 | If no units are specified, this primary evaluates to | |
279 | true if the difference between the time of last change of file status | |
44bd5ea7 A |
280 | information and the time |
281 | .Nm | |
e1a085ba | 282 | was started, rounded up to the next full 24-hour period, is |
44bd5ea7 | 283 | .Ar n |
e1a085ba A |
284 | 24-hour periods. |
285 | .Pp | |
286 | If units are specified, this primary evaluates to | |
287 | true if the difference between the time of last change of file status | |
288 | information and the time | |
289 | .Nm | |
290 | was started is exactly | |
291 | .Ar n | |
292 | units. | |
293 | Please refer to the | |
294 | .Ic -atime | |
295 | primary description for information on supported time units. | |
ddb4a88b A |
296 | .It Ic -d |
297 | Same as | |
298 | .Ic depth . | |
299 | GNU find implements this as a primary in mistaken emulation of | |
300 | .Fx | |
301 | .Xr find 1 . | |
c0fcf4e1 A |
302 | .It Ic -delete |
303 | Delete found files and/or directories. | |
304 | Always returns true. | |
305 | This executes | |
306 | from the current working directory as | |
307 | .Nm | |
308 | recurses down the tree. | |
309 | It will not attempt to delete a filename with a | |
310 | .Dq Pa / | |
311 | character in its pathname relative to | |
312 | .Dq Pa \&. | |
313 | for security reasons. | |
e1a085ba | 314 | Depth-first traversal processing is implied by this option. |
f14763b6 | 315 | Following symlinks is incompatible with this option. |
c0fcf4e1 A |
316 | .It Ic -depth |
317 | Always true; | |
318 | same as the | |
319 | .Fl d | |
320 | option. | |
e1a085ba A |
321 | .It Ic -depth Ar n |
322 | True if the depth of the file relative to the starting point of the traversal | |
323 | is | |
324 | .Ar n . | |
c0fcf4e1 A |
325 | .It Ic -empty |
326 | True if the current file or directory is empty. | |
e1a085ba | 327 | .It Ic -exec Ar utility Oo Ar argument ... Oc Li \&; |
44bd5ea7 A |
328 | True if the program named |
329 | .Ar utility | |
330 | returns a zero value as its exit status. | |
c0fcf4e1 A |
331 | Optional |
332 | .Ar arguments | |
333 | may be passed to the utility. | |
334 | The expression must be terminated by a semicolon | |
335 | .Pq Dq Li \&; . | |
e1a085ba A |
336 | If you invoke |
337 | .Nm | |
338 | from a shell you may need to quote the semicolon if the shell would | |
339 | otherwise treat it as a control operator. | |
c0fcf4e1 A |
340 | If the string |
341 | .Dq Li {} | |
342 | appears anywhere in the utility name or the | |
44bd5ea7 A |
343 | arguments it is replaced by the pathname of the current file. |
344 | .Ar Utility | |
345 | will be executed from the directory from which | |
346 | .Nm | |
347 | was executed. | |
c0fcf4e1 A |
348 | .Ar Utility |
349 | and | |
350 | .Ar arguments | |
351 | are not subject to the further expansion of shell patterns | |
352 | and constructs. | |
e1a085ba A |
353 | .It Ic -exec Ar utility Oo Ar argument ... Oc Li {} + |
354 | Same as | |
355 | .Ic -exec , | |
356 | except that | |
357 | .Dq Li {} | |
358 | is replaced with as many pathnames as possible for each invocation of | |
359 | .Ar utility . | |
360 | This behaviour is similar to that of | |
361 | .Xr xargs 1 . | |
362 | .It Ic -execdir Ar utility Oo Ar argument ... Oc Li \&; | |
c0fcf4e1 A |
363 | The |
364 | .Ic -execdir | |
365 | primary is identical to the | |
366 | .Ic -exec | |
367 | primary with the exception that | |
368 | .Ar utility | |
369 | will be executed from the directory that holds | |
370 | the current file. | |
371 | The filename substituted for | |
372 | the string | |
373 | .Dq Li {} | |
374 | is not qualified. | |
ddb4a88b A |
375 | .It Ic -execdir Ar utility Oo Ar argument ... Oc Li {} + |
376 | Same as | |
377 | .Ic -execdir , | |
378 | except that | |
379 | .Dq Li {} | |
380 | is replaced with as many pathnames as possible for each invocation of | |
381 | .Ar utility . | |
382 | This behaviour is similar to that of | |
383 | .Xr xargs 1 . | |
c0fcf4e1 A |
384 | .It Ic -flags Oo Cm - Ns | Ns Cm + Oc Ns Ar flags , Ns Ar notflags |
385 | The flags are specified using symbolic names (see | |
386 | .Xr chflags 1 ) . | |
387 | Those with the | |
388 | .Qq Li no | |
389 | prefix (except | |
390 | .Qq Li nodump ) | |
391 | are said to be | |
392 | .Ar notflags . | |
393 | Flags in | |
394 | .Ar flags | |
395 | are checked to be set, and flags in | |
396 | .Ar notflags | |
397 | are checked to be not set. | |
398 | Note that this is different from | |
399 | .Ic -perm , | |
400 | which only allows the user to specify mode bits that are set. | |
401 | .Pp | |
402 | If flags are preceded by a dash | |
403 | .Pq Dq Li - , | |
404 | this primary evaluates to true | |
405 | if at least all of the bits in | |
406 | .Ar flags | |
407 | and none of the bits in | |
408 | .Ar notflags | |
409 | are set in the file's flags bits. | |
410 | If flags are preceded by a plus | |
411 | .Pq Dq Li + , | |
412 | this primary evaluates to true | |
413 | if any of the bits in | |
414 | .Ar flags | |
415 | is set in the file's flags bits, | |
416 | or any of the bits in | |
417 | .Ar notflags | |
418 | is not set in the file's flags bits. | |
419 | Otherwise, | |
420 | this primary evaluates to true | |
421 | if the bits in | |
422 | .Ar flags | |
423 | exactly match the file's flags bits, | |
424 | and none of the | |
425 | .Ar flags | |
426 | bits match those of | |
427 | .Ar notflags . | |
428 | .It Ic -fstype Ar type | |
44bd5ea7 A |
429 | True if the file is contained in a file system of type |
430 | .Ar type . | |
431 | The | |
432 | .Xr sysctl 8 | |
e1a085ba | 433 | command can be used to find out the types of file systems |
44bd5ea7 | 434 | that are available on the system: |
c0fcf4e1 A |
435 | .Pp |
436 | .Dl "sysctl vfs" | |
437 | .Pp | |
438 | In addition, there are two pseudo-types, | |
439 | .Dq Li local | |
440 | and | |
441 | .Dq Li rdonly . | |
44bd5ea7 A |
442 | The former matches any file system physically mounted on the system where |
443 | the | |
444 | .Nm | |
c0fcf4e1 | 445 | is being executed and the latter matches any file system which is |
44bd5ea7 | 446 | mounted read-only. |
ddb4a88b A |
447 | .It Ic -gid Ar gname |
448 | The same thing as | |
449 | .Ar -group Ar gname | |
450 | for compatibility with GNU find. | |
451 | GNU find imposes a restriction that | |
452 | .Ar gname | |
453 | is numeric, while | |
454 | .Xr find 1 | |
455 | does not. | |
c0fcf4e1 | 456 | .It Ic -group Ar gname |
44bd5ea7 | 457 | True if the file belongs to the group |
c0fcf4e1 | 458 | .Ar gname . |
44bd5ea7 A |
459 | If |
460 | .Ar gname | |
461 | is numeric and there is no such group name, then | |
462 | .Ar gname | |
c0fcf4e1 | 463 | is treated as a group ID. |
ddb4a88b A |
464 | .It Ic -ignore_readdir_race |
465 | This option is for GNU find compatibility and is ignored. | |
466 | .It Ic -ilname Ar pattern | |
467 | Like | |
468 | .Ic -lname , | |
469 | but the match is case insensitive. | |
470 | This is a GNU find extension. | |
c0fcf4e1 A |
471 | .It Ic -iname Ar pattern |
472 | Like | |
473 | .Ic -name , | |
474 | but the match is case insensitive. | |
475 | .It Ic -inum Ar n | |
44bd5ea7 | 476 | True if the file has inode number |
c0fcf4e1 A |
477 | .Ar n . |
478 | .It Ic -ipath Ar pattern | |
479 | Like | |
480 | .Ic -path , | |
481 | but the match is case insensitive. | |
482 | .It Ic -iregex Ar pattern | |
483 | Like | |
484 | .Ic -regex , | |
485 | but the match is case insensitive. | |
ddb4a88b A |
486 | .It Ic -iwholename Ar pattern |
487 | The same thing as | |
488 | .Ic -ipath , | |
489 | for GNU find compatibility. | |
c0fcf4e1 | 490 | .It Ic -links Ar n |
44bd5ea7 A |
491 | True if the file has |
492 | .Ar n | |
493 | links. | |
ddb4a88b A |
494 | .It Ic -lname Ar pattern |
495 | Like | |
496 | .Ic -name , | |
497 | but the contents of the symbolic link are matched instead of the file | |
498 | name. | |
499 | This is a GNU find extension. | |
44bd5ea7 A |
500 | .It Ic -ls |
501 | This primary always evaluates to true. | |
502 | The following information for the current file is written to standard output: | |
e1a085ba | 503 | its inode number, size in 512-byte blocks, file permissions, number of hard |
44bd5ea7 A |
504 | links, owner, group, size in bytes, last modification time, and pathname. |
505 | If the file is a block or character special file, the major and minor numbers | |
506 | will be displayed instead of the size in bytes. | |
e1a085ba | 507 | If the file is a symbolic link, the pathname of the linked-to file will be |
c0fcf4e1 A |
508 | displayed preceded by |
509 | .Dq Li -> . | |
510 | The format is identical to that produced by | |
511 | .Bk -words | |
ddb4a88b | 512 | .Dq Nm ls Fl dgils . |
c0fcf4e1 A |
513 | .Ek |
514 | .It Ic -maxdepth Ar n | |
e1a085ba A |
515 | Always true; descend at most |
516 | .Ar n | |
517 | directory levels below the command line arguments. | |
518 | If any | |
519 | .Ic -maxdepth | |
520 | primary is specified, it applies to the entire expression even if it would | |
521 | not normally be evaluated. | |
ddb4a88b | 522 | .Dq Ic -maxdepth Li 0 |
e1a085ba | 523 | limits the whole search to the command line arguments. |
c0fcf4e1 | 524 | .It Ic -mindepth Ar n |
e1a085ba | 525 | Always true; do not apply any tests or actions at levels less than |
c0fcf4e1 | 526 | .Ar n . |
e1a085ba A |
527 | If any |
528 | .Ic -mindepth | |
529 | primary is specified, it applies to the entire expression even if it would | |
530 | not normally be evaluated. | |
ddb4a88b | 531 | .Dq Ic -mindepth Li 1 |
e1a085ba | 532 | processes all but the command line arguments. |
c0fcf4e1 A |
533 | .It Ic -mmin Ar n |
534 | True if the difference between the file last modification time and the time | |
535 | .Nm | |
536 | was started, rounded up to the next full minute, is | |
537 | .Ar n | |
538 | minutes. | |
539 | .It Ic -mnewer Ar file | |
540 | Same as | |
541 | .Ic -newer . | |
ddb4a88b A |
542 | .It Ic -mount |
543 | The same thing as | |
544 | .Ic -xdev , | |
545 | for GNU find compatibility. | |
e1a085ba A |
546 | .It Ic -mtime Ar n Ns Op Cm smhdw |
547 | If no units are specified, this primary evaluates to | |
548 | true if the difference between the file last modification time and the time | |
549 | .Nm | |
550 | was started, rounded up to the next full 24-hour period, is | |
551 | .Ar n | |
552 | 24-hour periods. | |
553 | .Pp | |
554 | If units are specified, this primary evaluates to | |
555 | true if the difference between the file last modification time and the time | |
44bd5ea7 | 556 | .Nm |
e1a085ba | 557 | was started is exactly |
44bd5ea7 | 558 | .Ar n |
e1a085ba A |
559 | units. |
560 | Please refer to the | |
561 | .Ic -atime | |
562 | primary description for information on supported time units. | |
c0fcf4e1 A |
563 | .It Ic -name Ar pattern |
564 | True if the last component of the pathname being examined matches | |
565 | .Ar pattern . | |
566 | Special shell pattern matching characters | |
567 | .Dq ( Li \&[ , | |
568 | .Dq Li \&] , | |
569 | .Dq Li * , | |
570 | and | |
571 | .Dq Li \&? ) | |
572 | may be used as part of | |
573 | .Ar pattern . | |
574 | These characters may be matched explicitly by escaping them with a | |
575 | backslash | |
576 | .Pq Dq Li \e . | |
577 | .It Ic -newer Ar file | |
578 | True if the current file has a more recent last modification time than | |
579 | .Ar file . | |
580 | .It Ic -newer Ns Ar X Ns Ar Y Ar file | |
581 | True if the current file has a more recent last access time | |
ddb4a88b | 582 | .Pq Ar X Ns = Ns Cm a , |
e1a085ba | 583 | inode creation time |
ddb4a88b | 584 | .Pq Ar X Ns = Ns Cm B , |
c0fcf4e1 | 585 | change time |
ddb4a88b | 586 | .Pq Ar X Ns = Ns Cm c , |
c0fcf4e1 | 587 | or modification time |
ddb4a88b | 588 | .Pq Ar X Ns = Ns Cm m |
c0fcf4e1 | 589 | than the last access time |
ddb4a88b | 590 | .Pq Ar Y Ns = Ns Cm a , |
e1a085ba | 591 | inode creation time |
ddb4a88b | 592 | .Pq Ar Y Ns = Ns Cm B , |
c0fcf4e1 | 593 | change time |
ddb4a88b | 594 | .Pq Ar Y Ns = Ns Cm c , |
c0fcf4e1 | 595 | or modification time |
ddb4a88b | 596 | .Pq Ar Y Ns = Ns Cm m |
c0fcf4e1 A |
597 | of |
598 | .Ar file . | |
599 | In addition, if | |
600 | .Ar Y Ns = Ns Cm t , | |
601 | then | |
602 | .Ar file | |
603 | is instead interpreted as a direct date specification of the form | |
604 | understood by | |
605 | .Xr cvs 1 . | |
606 | Note that | |
607 | .Ic -newermm | |
608 | is equivalent to | |
609 | .Ic -newer . | |
610 | .It Ic -nogroup | |
611 | True if the file belongs to an unknown group. | |
ddb4a88b A |
612 | .It Ic -noignore_readdir_race |
613 | This option is for GNU find compatibility and is ignored. | |
614 | .It Ic -noleaf | |
615 | This option is for GNU find compatibility. | |
616 | In GNU find it disables an optimization not relevant to | |
617 | .Xr find 1 , | |
618 | so it is ignored. | |
c0fcf4e1 A |
619 | .It Ic -nouser |
620 | True if the file belongs to an unknown user. | |
e1a085ba | 621 | .It Ic -ok Ar utility Oo Ar argument ... Oc Li \&; |
44bd5ea7 | 622 | The |
c0fcf4e1 | 623 | .Ic -ok |
44bd5ea7 A |
624 | primary is identical to the |
625 | .Ic -exec | |
626 | primary with the exception that | |
627 | .Nm | |
c0fcf4e1 A |
628 | requests user affirmation for the execution of the |
629 | .Ar utility | |
630 | by printing | |
44bd5ea7 | 631 | a message to the terminal and reading a response. |
e1a085ba A |
632 | If the response is not affirmative |
633 | .Ql ( y | |
634 | in the | |
635 | .Dq Li POSIX | |
636 | locale), | |
c0fcf4e1 | 637 | the command is not executed and the |
44bd5ea7 | 638 | value of the |
c0fcf4e1 | 639 | .Ic -ok |
44bd5ea7 | 640 | expression is false. |
e1a085ba | 641 | .It Ic -okdir Ar utility Oo Ar argument ... Oc Li \&; |
c0fcf4e1 A |
642 | The |
643 | .Ic -okdir | |
644 | primary is identical to the | |
645 | .Ic -execdir | |
646 | primary with the same exception as described for the | |
647 | .Ic -ok | |
648 | primary. | |
649 | .It Ic -path Ar pattern | |
44bd5ea7 | 650 | True if the pathname being examined matches |
c0fcf4e1 A |
651 | .Ar pattern . |
652 | Special shell pattern matching characters | |
653 | .Dq ( Li \&[ , | |
654 | .Dq Li \&] , | |
655 | .Dq Li * , | |
656 | and | |
657 | .Dq Li \&? ) | |
44bd5ea7 | 658 | may be used as part of |
c0fcf4e1 | 659 | .Ar pattern . |
44bd5ea7 | 660 | These characters may be matched explicitly by escaping them with a |
c0fcf4e1 A |
661 | backslash |
662 | .Pq Dq Li \e . | |
663 | Slashes | |
664 | .Pq Dq Li / | |
665 | are treated as normal characters and do not have to be | |
44bd5ea7 | 666 | matched explicitly. |
c0fcf4e1 | 667 | .It Ic -perm Oo Cm - Ns | Ns Cm + Oc Ns Ar mode |
44bd5ea7 A |
668 | The |
669 | .Ar mode | |
670 | may be either symbolic (see | |
c0fcf4e1 | 671 | .Xr chmod 1 ) |
44bd5ea7 | 672 | or an octal number. |
c0fcf4e1 A |
673 | If the |
674 | .Ar mode | |
675 | is symbolic, a starting value of zero is assumed and the | |
676 | .Ar mode | |
677 | sets or clears permissions without regard to the process' file mode | |
44bd5ea7 | 678 | creation mask. |
c0fcf4e1 A |
679 | If the |
680 | .Ar mode | |
681 | is octal, only bits 07777 | |
682 | .Pq Dv S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO | |
44bd5ea7 A |
683 | of the file's mode bits participate |
684 | in the comparison. | |
c0fcf4e1 A |
685 | If the |
686 | .Ar mode | |
687 | is preceded by a dash | |
688 | .Pq Dq Li - , | |
689 | this primary evaluates to true | |
690 | if at least all of the bits in the | |
691 | .Ar mode | |
692 | are set in the file's mode bits. | |
693 | If the | |
694 | .Ar mode | |
695 | is preceded by a plus | |
696 | .Pq Dq Li + , | |
697 | this primary evaluates to true | |
698 | if any of the bits in the | |
699 | .Ar mode | |
700 | are set in the file's mode bits. | |
701 | Otherwise, this primary evaluates to true if | |
702 | the bits in the | |
703 | .Ar mode | |
704 | exactly match the file's mode bits. | |
705 | Note, the first character of a symbolic mode may not be a dash | |
706 | .Pq Dq Li - . | |
44bd5ea7 A |
707 | .It Ic -print |
708 | This primary always evaluates to true. | |
c0fcf4e1 | 709 | It prints the pathname of the current file to standard output. |
44bd5ea7 | 710 | If none of |
e1a085ba A |
711 | .\" 4772561 |
712 | .Ic -exec , -ls , -print , -print0 , | |
c0fcf4e1 A |
713 | or |
714 | .Ic -ok | |
44bd5ea7 | 715 | is specified, the given expression shall be effectively replaced by |
c0fcf4e1 | 716 | .Cm \&( Ar "given expression" Cm \&) Ic -print . |
44bd5ea7 A |
717 | .It Ic -print0 |
718 | This primary always evaluates to true. | |
c0fcf4e1 | 719 | It prints the pathname of the current file to standard output, followed by an |
e1a085ba A |
720 | .Tn ASCII |
721 | .Dv NUL | |
c0fcf4e1 | 722 | character (character code 0). |
44bd5ea7 A |
723 | .It Ic -prune |
724 | This primary always evaluates to true. | |
725 | It causes | |
726 | .Nm | |
727 | to not descend into the current file. | |
728 | Note, the | |
729 | .Ic -prune | |
730 | primary has no effect if the | |
731 | .Fl d | |
732 | option was specified. | |
c0fcf4e1 A |
733 | .It Ic -regex Ar pattern |
734 | True if the whole path of the file matches | |
735 | .Ar pattern | |
736 | using regular expression. | |
737 | To match a file named | |
738 | .Dq Pa ./foo/xyzzy , | |
739 | you can use the regular expression | |
740 | .Dq Li ".*/[xyz]*" | |
741 | or | |
742 | .Dq Li ".*/foo/.*" , | |
743 | but not | |
744 | .Dq Li xyzzy | |
745 | or | |
746 | .Dq Li /foo/ . | |
ddb4a88b A |
747 | .It Ic -samefile Ar name |
748 | True if the file is a hard link to | |
749 | .Ar name . | |
750 | If the command option | |
751 | .Ic -L | |
752 | is specified, it is also true if the file is a symbolic link and | |
753 | points to | |
754 | .Ar name . | |
e1a085ba A |
755 | .It Ic -size Ar n Ns Op Cm ckMGTP |
756 | True if the file's size, rounded up, in 512-byte blocks is | |
c0fcf4e1 | 757 | .Ar n . |
44bd5ea7 A |
758 | If |
759 | .Ar n | |
c0fcf4e1 A |
760 | is followed by a |
761 | .Cm c , | |
762 | then the primary is true if the | |
44bd5ea7 A |
763 | file's size is |
764 | .Ar n | |
c0fcf4e1 | 765 | bytes (characters). |
e1a085ba A |
766 | Similarly if |
767 | .Ar n | |
768 | is followed by a scale indicator then the file's size is compared to | |
769 | .Ar n | |
770 | scaled as: | |
771 | .Pp | |
772 | .Bl -tag -width indent -compact | |
773 | .It Cm k | |
774 | kilobytes (1024 bytes) | |
775 | .It Cm M | |
776 | megabytes (1024 kilobytes) | |
777 | .It Cm G | |
778 | gigabytes (1024 megabytes) | |
779 | .It Cm T | |
780 | terabytes (1024 gigabytes) | |
781 | .It Cm P | |
782 | petabytes (1024 terabytes) | |
783 | .El | |
c0fcf4e1 | 784 | .It Ic -type Ar t |
44bd5ea7 A |
785 | True if the file is of the specified type. |
786 | Possible file types are as follows: | |
787 | .Pp | |
c0fcf4e1 | 788 | .Bl -tag -width indent -compact |
44bd5ea7 A |
789 | .It Cm b |
790 | block special | |
791 | .It Cm c | |
792 | character special | |
793 | .It Cm d | |
794 | directory | |
795 | .It Cm f | |
796 | regular file | |
797 | .It Cm l | |
798 | symbolic link | |
799 | .It Cm p | |
800 | FIFO | |
801 | .It Cm s | |
802 | socket | |
803 | .El | |
ddb4a88b A |
804 | .It Ic -uid Ar uname |
805 | The same thing as | |
806 | .Ar -user Ar uname | |
807 | for compatibility with GNU find. | |
808 | GNU find imposes a restriction that | |
809 | .Ar uname | |
810 | is numeric, while | |
811 | .Xr find 1 | |
812 | does not. | |
c0fcf4e1 | 813 | .It Ic -user Ar uname |
44bd5ea7 | 814 | True if the file belongs to the user |
c0fcf4e1 | 815 | .Ar uname . |
44bd5ea7 A |
816 | If |
817 | .Ar uname | |
818 | is numeric and there is no such user name, then | |
819 | .Ar uname | |
c0fcf4e1 | 820 | is treated as a user ID. |
ddb4a88b A |
821 | .It Ic -wholename Ar pattern |
822 | The same thing as | |
823 | .Ic -path , | |
824 | for GNU find compatibility. | |
f14763b6 A |
825 | .It Ic -xattr |
826 | True if the file has any extended attributes. | |
827 | .It Ic -xattrname Ar name | |
828 | True if the file has an extended attribute with the specified | |
829 | .Ar name . | |
44bd5ea7 A |
830 | .El |
831 | .Pp | |
832 | All primaries which take a numeric argument allow the number to be | |
c0fcf4e1 A |
833 | preceded by a plus sign |
834 | .Pq Dq Li + | |
835 | or a minus sign | |
836 | .Pq Dq Li - . | |
837 | A preceding plus sign means | |
838 | .Dq more than n , | |
839 | a preceding minus sign means | |
840 | .Dq less than n | |
841 | and neither means | |
842 | .Dq exactly n . | |
44bd5ea7 A |
843 | .Sh OPERATORS |
844 | The primaries may be combined using the following operators. | |
845 | The operators are listed in order of decreasing precedence. | |
c0fcf4e1 | 846 | .Pp |
ddb4a88b | 847 | .Bl -tag -width indent -compact |
c0fcf4e1 | 848 | .It Cm \&( Ar expression Cm \&) |
44bd5ea7 A |
849 | This evaluates to true if the parenthesized expression evaluates to |
850 | true. | |
851 | .Pp | |
e1a085ba | 852 | .It Cm \&! Ar expression |
9bafe280 | 853 | .It Cm -not Ar expression |
44bd5ea7 A |
854 | This is the unary |
855 | .Tn NOT | |
856 | operator. | |
857 | It evaluates to true if the expression is false. | |
858 | .Pp | |
ddb4a88b A |
859 | .It Cm -false |
860 | Always false. | |
861 | .It Cm -true | |
862 | Always true. | |
863 | .Pp | |
c0fcf4e1 A |
864 | .It Ar expression Cm -and Ar expression |
865 | .It Ar expression expression | |
44bd5ea7 A |
866 | The |
867 | .Cm -and | |
868 | operator is the logical | |
869 | .Tn AND | |
870 | operator. | |
871 | As it is implied by the juxtaposition of two expressions it does not | |
872 | have to be specified. | |
873 | The expression evaluates to true if both expressions are true. | |
874 | The second expression is not evaluated if the first expression is false. | |
875 | .Pp | |
c0fcf4e1 | 876 | .It Ar expression Cm -or Ar expression |
44bd5ea7 A |
877 | The |
878 | .Cm -or | |
879 | operator is the logical | |
880 | .Tn OR | |
881 | operator. | |
882 | The expression evaluates to true if either the first or the second expression | |
883 | is true. | |
884 | The second expression is not evaluated if the first expression is true. | |
885 | .El | |
886 | .Pp | |
887 | All operands and primaries must be separate arguments to | |
c0fcf4e1 | 888 | .Nm . |
44bd5ea7 A |
889 | Primaries which themselves take arguments expect each argument |
890 | to be a separate argument to | |
c0fcf4e1 | 891 | .Nm . |
e1a085ba A |
892 | .Sh ENVIRONMENT |
893 | The | |
894 | .Ev LANG , LC_ALL , LC_COLLATE , LC_CTYPE , LC_MESSAGES | |
895 | and | |
896 | .Ev LC_TIME | |
897 | environment variables affect the execution of the | |
898 | .Nm | |
899 | utility as described in | |
900 | .Xr environ 7 . | |
44bd5ea7 | 901 | .Sh EXAMPLES |
44bd5ea7 | 902 | The following examples are shown as given to the shell: |
c0fcf4e1 A |
903 | .Bl -tag -width indent |
904 | .It Li "find / \e! -name \*q*.c\*q -print" | |
905 | Print out a list of all the files whose names do not end in | |
906 | .Pa .c . | |
907 | .It Li "find / -newer ttt -user wnj -print" | |
908 | Print out a list of all the files owned by user | |
909 | .Dq wnj | |
910 | that are newer | |
911 | than the file | |
912 | .Pa ttt . | |
913 | .It Li "find / \e! \e( -newer ttt -user wnj \e) -print" | |
914 | Print out a list of all the files which are not both newer than | |
915 | .Pa ttt | |
916 | and owned by | |
917 | .Dq wnj . | |
918 | .It Li "find / \e( -newer ttt -or -user wnj \e) -print" | |
919 | Print out a list of all the files that are either owned by | |
920 | .Dq wnj | |
921 | or that are newer than | |
922 | .Pa ttt . | |
e1a085ba | 923 | .It Li "find / -newerct '1 minute ago' -print" |
c0fcf4e1 A |
924 | Print out a list of all the files whose inode change time is more |
925 | recent than the current time minus one minute. | |
e1a085ba A |
926 | .It Li "find / -type f -exec echo {} \e;" |
927 | Use the | |
928 | .Xr echo 1 | |
929 | command to print out a list of all the files. | |
f14763b6 | 930 | .It Li "find -L /usr/ports/packages -type l -exec rm -- {} +" |
e1a085ba A |
931 | Delete all broken symbolic links in |
932 | .Pa /usr/ports/packages . | |
933 | .It Li "find /usr/src -name CVS -prune -o -depth +6 -print" | |
934 | Find files and directories that are at least seven levels deep | |
935 | in the working directory | |
936 | .Pa /usr/src . | |
937 | .It Li "find /usr/src -name CVS -prune -o -mindepth 7 -print" | |
938 | Is not equivalent to the previous example, since | |
939 | .Ic -prune | |
940 | is not evaluated below level seven. | |
44bd5ea7 | 941 | .El |
e1a085ba A |
942 | .Sh COMPATIBILITY |
943 | The | |
944 | .Ic -follow | |
945 | primary is deprecated; the | |
946 | .Fl L | |
947 | option should be used instead. | |
948 | See the | |
949 | .Sx STANDARDS | |
950 | section below for details. | |
44bd5ea7 | 951 | .Sh SEE ALSO |
c0fcf4e1 | 952 | .Xr chflags 1 , |
44bd5ea7 | 953 | .Xr chmod 1 , |
c0fcf4e1 | 954 | .Xr cvs 1 , |
44bd5ea7 | 955 | .Xr locate 1 , |
c0fcf4e1 A |
956 | .Xr whereis 1 , |
957 | .Xr which 1 , | |
e1a085ba | 958 | .Xr xargs 1 , |
44bd5ea7 | 959 | .Xr stat 2 , |
f14763b6 | 960 | .Xr acl 3 , |
44bd5ea7 | 961 | .Xr fts 3 , |
44bd5ea7 | 962 | .Xr getgrent 3 , |
c0fcf4e1 | 963 | .Xr getpwent 3 , |
44bd5ea7 | 964 | .Xr strmode 3 , |
c0fcf4e1 | 965 | .Xr re_format 7 , |
44bd5ea7 A |
966 | .Xr symlink 7 |
967 | .Sh STANDARDS | |
968 | The | |
969 | .Nm | |
970 | utility syntax is a superset of the syntax specified by the | |
e1a085ba | 971 | .St -p1003.1-2001 |
44bd5ea7 A |
972 | standard. |
973 | .Pp | |
e1a085ba | 974 | All the single character options except |
ddb4a88b | 975 | .Fl H |
44bd5ea7 | 976 | and |
ddb4a88b | 977 | .Fl L |
e1a085ba A |
978 | as well as |
979 | .Ic -amin , -anewer , -cmin , -cnewer , -delete , -empty , -fstype , | |
980 | .Ic -iname , -inum , -iregex , -ls , -maxdepth , -mindepth , -mmin , | |
981 | .Ic -path , -print0 , -regex | |
982 | and all of the | |
ddb4a88b | 983 | .Ic -B* |
e1a085ba A |
984 | birthtime related primaries are extensions to |
985 | .St -p1003.1-2001 . | |
44bd5ea7 A |
986 | .Pp |
987 | Historically, the | |
e1a085ba | 988 | .Fl d , L |
44bd5ea7 A |
989 | and |
990 | .Fl x | |
c0fcf4e1 A |
991 | options were implemented using the primaries |
992 | .Ic -depth , -follow , | |
993 | and | |
994 | .Ic -xdev . | |
44bd5ea7 A |
995 | These primaries always evaluated to true. |
996 | As they were really global variables that took effect before the traversal | |
997 | began, some legal expressions could have unexpected results. | |
c0fcf4e1 A |
998 | An example is the expression |
999 | .Ic -print Cm -o Ic -depth . | |
1000 | As | |
1001 | .Ic -print | |
1002 | always evaluates to true, the standard order of evaluation | |
1003 | implies that | |
1004 | .Ic -depth | |
1005 | would never be evaluated. | |
44bd5ea7 A |
1006 | This is not the case. |
1007 | .Pp | |
c0fcf4e1 A |
1008 | The operator |
1009 | .Cm -or | |
1010 | was implemented as | |
1011 | .Cm -o , | |
1012 | and the operator | |
1013 | .Cm -and | |
1014 | was implemented as | |
1015 | .Cm -a . | |
44bd5ea7 A |
1016 | .Pp |
1017 | Historic implementations of the | |
1018 | .Ic -exec | |
1019 | and | |
1020 | .Ic -ok | |
c0fcf4e1 A |
1021 | primaries did not replace the string |
1022 | .Dq Li {} | |
1023 | in the utility name or the | |
44bd5ea7 A |
1024 | utility arguments if it had preceding or following non-whitespace characters. |
1025 | This version replaces it no matter where in the utility name or arguments | |
1026 | it appears. | |
c0fcf4e1 A |
1027 | .Pp |
1028 | The | |
1029 | .Fl E | |
e1a085ba | 1030 | option was inspired by the equivalent |
c0fcf4e1 A |
1031 | .Xr grep 1 |
1032 | and | |
e1a085ba A |
1033 | .Xr sed 1 |
1034 | options. | |
1035 | .Sh HISTORY | |
1036 | A | |
1037 | .Nm | |
1038 | command appeared in | |
1039 | .At v1 . | |
44bd5ea7 A |
1040 | .Sh BUGS |
1041 | The special characters used by | |
1042 | .Nm | |
1043 | are also special characters to many shell programs. | |
c0fcf4e1 A |
1044 | In particular, the characters |
1045 | .Dq Li * , | |
1046 | .Dq Li \&[ , | |
1047 | .Dq Li \&] , | |
1048 | .Dq Li \&? , | |
1049 | .Dq Li \&( , | |
1050 | .Dq Li \&) , | |
1051 | .Dq Li \&! , | |
1052 | .Dq Li \e | |
1053 | and | |
1054 | .Dq Li \&; | |
1055 | may have to be escaped from the shell. | |
44bd5ea7 A |
1056 | .Pp |
1057 | As there is no delimiter separating options and file names or file | |
1058 | names and the | |
1059 | .Ar expression , | |
c0fcf4e1 A |
1060 | it is difficult to specify files named |
1061 | .Pa -xdev | |
1062 | or | |
1063 | .Pa \&! . | |
44bd5ea7 A |
1064 | These problems are handled by the |
1065 | .Fl f | |
1066 | option and the | |
1067 | .Xr getopt 3 | |
c0fcf4e1 A |
1068 | .Dq Fl Fl |
1069 | construct. | |
1070 | .Pp | |
1071 | The | |
1072 | .Ic -delete | |
e1a085ba | 1073 | primary does not interact well with other options that cause the file system |
c0fcf4e1 | 1074 | tree traversal options to be changed. |
e1a085ba A |
1075 | .Pp |
1076 | The | |
1077 | .Ic -mindepth | |
1078 | and | |
1079 | .Ic -maxdepth | |
1080 | primaries are actually global options (as documented above). | |
1081 | They should | |
1082 | probably be replaced by options which look like options. |