]>
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 |
e1a085ba | 36 | .\" $FreeBSD: src/usr.bin/find/find.1,v 1.81 2006/12/13 17:02:50 ru Exp $ |
44bd5ea7 | 37 | .\" |
e1a085ba | 38 | .Dd December 13, 2006 |
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 A |
47 | .Op Fl EXdsx |
48 | .Op Fl f Ar pathname | |
e1a085ba A |
49 | .Ar pathname ... |
50 | .Ar expression | |
51 | .Nm | |
52 | .Op Fl H | Fl L | Fl P | |
53 | .Op Fl EXdsx | |
54 | .Fl f Ar pathname | |
c0fcf4e1 | 55 | .Op Ar pathname ... |
44bd5ea7 A |
56 | .Ar expression |
57 | .Sh DESCRIPTION | |
e1a085ba A |
58 | The |
59 | .Nm | |
60 | utility recursively descends the directory tree for each | |
c0fcf4e1 | 61 | .Ar pathname |
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 | |
78 | options as extended (modern) regular expressions rather than basic | |
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 . | |
147 | .Fl d | |
148 | can be useful when | |
149 | .Nm | |
150 | is used with | |
151 | .Xr cpio 1 | |
152 | to process files that are contained in directories with unusual permissions. | |
153 | It ensures that you have write permission while you are placing files in a | |
154 | directory, then sets the directory's permissions as the last thing. | |
44bd5ea7 | 155 | .It Fl f |
e1a085ba | 156 | Specify a file hierarchy for |
44bd5ea7 A |
157 | .Nm |
158 | to traverse. | |
159 | File hierarchies may also be specified as the operands immediately | |
160 | following the options. | |
c0fcf4e1 | 161 | .It Fl s |
e1a085ba | 162 | Cause |
c0fcf4e1 A |
163 | .Nm |
164 | to traverse the file hierarchies in lexicographical order, | |
165 | i.e., alphabetical order within each directory. | |
166 | Note: | |
167 | .Ql find -s | |
168 | and | |
169 | .Ql "find | sort" | |
170 | may give different results. | |
44bd5ea7 | 171 | .It Fl x |
e1a085ba | 172 | Prevent |
44bd5ea7 A |
173 | .Nm |
174 | from descending into directories that have a device number different | |
175 | than that of the file from which the descent began. | |
e1a085ba A |
176 | .Pp |
177 | This option is equivalent to the deprecated | |
178 | .Ic -xdev | |
179 | primary. | |
44bd5ea7 A |
180 | .El |
181 | .Sh PRIMARIES | |
c0fcf4e1 | 182 | .Bl -tag -width indent |
e1a085ba A |
183 | .It Ic -Bmin Ar n |
184 | True if the difference between the time of a file's inode creation | |
185 | and the time | |
186 | .Nm | |
187 | was started, rounded up to the next full minute, is | |
188 | .Ar n | |
189 | minutes. | |
190 | .It Ic -Bnewer Ar file | |
191 | Same as | |
192 | .Ic -newerBm . | |
193 | .It Ic -Btime Ar n Ns Op Cm smhdw | |
194 | If no units are specified, this primary evaluates to | |
195 | true if the difference between the time of a file's inode creation | |
196 | and the time | |
197 | .Nm | |
198 | was started, rounded up to the next full 24-hour period, is | |
199 | .Ar n | |
200 | 24-hour periods. | |
201 | .Pp | |
202 | If units are specified, this primary evaluates to | |
203 | true if the difference between the time of a file's inode creation | |
204 | and the time | |
205 | .Nm | |
206 | was started is exactly | |
207 | .Ar n | |
208 | units. | |
209 | Please refer to the | |
210 | .Ic -atime | |
211 | primary description for information on supported time units. | |
212 | .\" .It Ic -acl | |
213 | .\" May be used in conjunction with other options to locate | |
214 | .\" files with extended ACLs. | |
215 | .\" See | |
216 | .\" .Xr acl 3 | |
217 | .\" for more information. | |
c0fcf4e1 A |
218 | .It Ic -amin Ar n |
219 | True if the difference between the file last access time and the time | |
220 | .Nm | |
221 | was started, rounded up to the next full minute, is | |
222 | .Ar n | |
223 | minutes. | |
224 | .It Ic -anewer Ar file | |
225 | Same as | |
226 | .Ic -neweram . | |
e1a085ba A |
227 | .It Ic -atime Ar n Ns Op Cm smhdw |
228 | If no units are specified, this primary evaluates to | |
229 | true if the difference between the file last access time and the time | |
230 | .Nm | |
231 | was started, rounded up to the next full 24-hour period, is | |
232 | .Ar n | |
233 | 24-hour periods. | |
234 | .Pp | |
235 | If units are specified, this primary evaluates to | |
236 | true if the difference between the file last access time and the time | |
44bd5ea7 | 237 | .Nm |
e1a085ba | 238 | was started is exactly |
44bd5ea7 | 239 | .Ar n |
e1a085ba A |
240 | units. |
241 | Possible time units are as follows: | |
242 | .Pp | |
243 | .Bl -tag -width indent -compact | |
244 | .It Cm s | |
245 | second | |
246 | .It Cm m | |
247 | minute (60 seconds) | |
248 | .It Cm h | |
249 | hour (60 minutes) | |
250 | .It Cm d | |
251 | day (24 hours) | |
252 | .It Cm w | |
253 | week (7 days) | |
254 | .El | |
255 | .Pp | |
256 | Any number of units may be combined in one | |
257 | .Ic -atime | |
258 | argument, for example, | |
259 | .Dq Li "-atime -1h30m" . | |
260 | Units are probably only useful when used in conjunction with the | |
261 | .Cm + | |
262 | or | |
263 | .Cm - | |
264 | modifier. | |
c0fcf4e1 A |
265 | .It Ic -cmin Ar n |
266 | True if the difference between the time of last change of file status | |
267 | information and the time | |
268 | .Nm | |
269 | was started, rounded up to the next full minute, is | |
270 | .Ar n | |
271 | minutes. | |
272 | .It Ic -cnewer Ar file | |
273 | Same as | |
274 | .Ic -newercm . | |
e1a085ba A |
275 | .It Ic -ctime Ar n Ns Op Cm smhdw |
276 | If no units are specified, this primary evaluates to | |
277 | true if the difference between the time of last change of file status | |
44bd5ea7 A |
278 | information and the time |
279 | .Nm | |
e1a085ba | 280 | was started, rounded up to the next full 24-hour period, is |
44bd5ea7 | 281 | .Ar n |
e1a085ba A |
282 | 24-hour periods. |
283 | .Pp | |
284 | If units are specified, this primary evaluates to | |
285 | true if the difference between the time of last change of file status | |
286 | information and the time | |
287 | .Nm | |
288 | was started is exactly | |
289 | .Ar n | |
290 | units. | |
291 | Please refer to the | |
292 | .Ic -atime | |
293 | primary description for information on supported time units. | |
c0fcf4e1 A |
294 | .It Ic -delete |
295 | Delete found files and/or directories. | |
296 | Always returns true. | |
297 | This executes | |
298 | from the current working directory as | |
299 | .Nm | |
300 | recurses down the tree. | |
301 | It will not attempt to delete a filename with a | |
302 | .Dq Pa / | |
303 | character in its pathname relative to | |
304 | .Dq Pa \&. | |
305 | for security reasons. | |
e1a085ba | 306 | Depth-first traversal processing is implied by this option. |
c0fcf4e1 A |
307 | .It Ic -depth |
308 | Always true; | |
309 | same as the | |
310 | .Fl d | |
311 | option. | |
e1a085ba A |
312 | .It Ic -depth Ar n |
313 | True if the depth of the file relative to the starting point of the traversal | |
314 | is | |
315 | .Ar n . | |
c0fcf4e1 A |
316 | .It Ic -empty |
317 | True if the current file or directory is empty. | |
e1a085ba | 318 | .It Ic -exec Ar utility Oo Ar argument ... Oc Li \&; |
44bd5ea7 A |
319 | True if the program named |
320 | .Ar utility | |
321 | returns a zero value as its exit status. | |
c0fcf4e1 A |
322 | Optional |
323 | .Ar arguments | |
324 | may be passed to the utility. | |
325 | The expression must be terminated by a semicolon | |
326 | .Pq Dq Li \&; . | |
e1a085ba A |
327 | If you invoke |
328 | .Nm | |
329 | from a shell you may need to quote the semicolon if the shell would | |
330 | otherwise treat it as a control operator. | |
c0fcf4e1 A |
331 | If the string |
332 | .Dq Li {} | |
333 | appears anywhere in the utility name or the | |
44bd5ea7 A |
334 | arguments it is replaced by the pathname of the current file. |
335 | .Ar Utility | |
336 | will be executed from the directory from which | |
337 | .Nm | |
338 | was executed. | |
c0fcf4e1 A |
339 | .Ar Utility |
340 | and | |
341 | .Ar arguments | |
342 | are not subject to the further expansion of shell patterns | |
343 | and constructs. | |
e1a085ba A |
344 | .It Ic -exec Ar utility Oo Ar argument ... Oc Li {} + |
345 | Same as | |
346 | .Ic -exec , | |
347 | except that | |
348 | .Dq Li {} | |
349 | is replaced with as many pathnames as possible for each invocation of | |
350 | .Ar utility . | |
351 | This behaviour is similar to that of | |
352 | .Xr xargs 1 . | |
353 | .It Ic -execdir Ar utility Oo Ar argument ... Oc Li \&; | |
c0fcf4e1 A |
354 | The |
355 | .Ic -execdir | |
356 | primary is identical to the | |
357 | .Ic -exec | |
358 | primary with the exception that | |
359 | .Ar utility | |
360 | will be executed from the directory that holds | |
361 | the current file. | |
362 | The filename substituted for | |
363 | the string | |
364 | .Dq Li {} | |
365 | is not qualified. | |
366 | .It Ic -flags Oo Cm - Ns | Ns Cm + Oc Ns Ar flags , Ns Ar notflags | |
367 | The flags are specified using symbolic names (see | |
368 | .Xr chflags 1 ) . | |
369 | Those with the | |
370 | .Qq Li no | |
371 | prefix (except | |
372 | .Qq Li nodump ) | |
373 | are said to be | |
374 | .Ar notflags . | |
375 | Flags in | |
376 | .Ar flags | |
377 | are checked to be set, and flags in | |
378 | .Ar notflags | |
379 | are checked to be not set. | |
380 | Note that this is different from | |
381 | .Ic -perm , | |
382 | which only allows the user to specify mode bits that are set. | |
383 | .Pp | |
384 | If flags are preceded by a dash | |
385 | .Pq Dq Li - , | |
386 | this primary evaluates to true | |
387 | if at least all of the bits in | |
388 | .Ar flags | |
389 | and none of the bits in | |
390 | .Ar notflags | |
391 | are set in the file's flags bits. | |
392 | If flags are preceded by a plus | |
393 | .Pq Dq Li + , | |
394 | this primary evaluates to true | |
395 | if any of the bits in | |
396 | .Ar flags | |
397 | is set in the file's flags bits, | |
398 | or any of the bits in | |
399 | .Ar notflags | |
400 | is not set in the file's flags bits. | |
401 | Otherwise, | |
402 | this primary evaluates to true | |
403 | if the bits in | |
404 | .Ar flags | |
405 | exactly match the file's flags bits, | |
406 | and none of the | |
407 | .Ar flags | |
408 | bits match those of | |
409 | .Ar notflags . | |
410 | .It Ic -fstype Ar type | |
44bd5ea7 A |
411 | True if the file is contained in a file system of type |
412 | .Ar type . | |
413 | The | |
414 | .Xr sysctl 8 | |
e1a085ba | 415 | command can be used to find out the types of file systems |
44bd5ea7 | 416 | that are available on the system: |
c0fcf4e1 A |
417 | .Pp |
418 | .Dl "sysctl vfs" | |
419 | .Pp | |
420 | In addition, there are two pseudo-types, | |
421 | .Dq Li local | |
422 | and | |
423 | .Dq Li rdonly . | |
44bd5ea7 A |
424 | The former matches any file system physically mounted on the system where |
425 | the | |
426 | .Nm | |
c0fcf4e1 | 427 | is being executed and the latter matches any file system which is |
44bd5ea7 | 428 | mounted read-only. |
c0fcf4e1 | 429 | .It Ic -group Ar gname |
44bd5ea7 | 430 | True if the file belongs to the group |
c0fcf4e1 | 431 | .Ar gname . |
44bd5ea7 A |
432 | If |
433 | .Ar gname | |
434 | is numeric and there is no such group name, then | |
435 | .Ar gname | |
c0fcf4e1 A |
436 | is treated as a group ID. |
437 | .It Ic -iname Ar pattern | |
438 | Like | |
439 | .Ic -name , | |
440 | but the match is case insensitive. | |
441 | .It Ic -inum Ar n | |
44bd5ea7 | 442 | True if the file has inode number |
c0fcf4e1 A |
443 | .Ar n . |
444 | .It Ic -ipath Ar pattern | |
445 | Like | |
446 | .Ic -path , | |
447 | but the match is case insensitive. | |
448 | .It Ic -iregex Ar pattern | |
449 | Like | |
450 | .Ic -regex , | |
451 | but the match is case insensitive. | |
452 | .It Ic -links Ar n | |
44bd5ea7 A |
453 | True if the file has |
454 | .Ar n | |
455 | links. | |
456 | .It Ic -ls | |
457 | This primary always evaluates to true. | |
458 | The following information for the current file is written to standard output: | |
e1a085ba | 459 | its inode number, size in 512-byte blocks, file permissions, number of hard |
44bd5ea7 A |
460 | links, owner, group, size in bytes, last modification time, and pathname. |
461 | If the file is a block or character special file, the major and minor numbers | |
462 | will be displayed instead of the size in bytes. | |
e1a085ba | 463 | If the file is a symbolic link, the pathname of the linked-to file will be |
c0fcf4e1 A |
464 | displayed preceded by |
465 | .Dq Li -> . | |
466 | The format is identical to that produced by | |
467 | .Bk -words | |
468 | .Nm ls Fl dgils . | |
469 | .Ek | |
470 | .It Ic -maxdepth Ar n | |
e1a085ba A |
471 | Always true; descend at most |
472 | .Ar n | |
473 | directory levels below the command line arguments. | |
474 | If any | |
475 | .Ic -maxdepth | |
476 | primary is specified, it applies to the entire expression even if it would | |
477 | not normally be evaluated. | |
478 | .Ic -maxdepth Li 0 | |
479 | limits the whole search to the command line arguments. | |
c0fcf4e1 | 480 | .It Ic -mindepth Ar n |
e1a085ba | 481 | Always true; do not apply any tests or actions at levels less than |
c0fcf4e1 | 482 | .Ar n . |
e1a085ba A |
483 | If any |
484 | .Ic -mindepth | |
485 | primary is specified, it applies to the entire expression even if it would | |
486 | not normally be evaluated. | |
487 | .Ic -mindepth Li 1 | |
488 | processes all but the command line arguments. | |
c0fcf4e1 A |
489 | .It Ic -mmin Ar n |
490 | True if the difference between the file last modification time and the time | |
491 | .Nm | |
492 | was started, rounded up to the next full minute, is | |
493 | .Ar n | |
494 | minutes. | |
495 | .It Ic -mnewer Ar file | |
496 | Same as | |
497 | .Ic -newer . | |
e1a085ba A |
498 | .It Ic -mtime Ar n Ns Op Cm smhdw |
499 | If no units are specified, this primary evaluates to | |
500 | true if the difference between the file last modification time and the time | |
501 | .Nm | |
502 | was started, rounded up to the next full 24-hour period, is | |
503 | .Ar n | |
504 | 24-hour periods. | |
505 | .Pp | |
506 | If units are specified, this primary evaluates to | |
507 | true if the difference between the file last modification time and the time | |
44bd5ea7 | 508 | .Nm |
e1a085ba | 509 | was started is exactly |
44bd5ea7 | 510 | .Ar n |
e1a085ba A |
511 | units. |
512 | Please refer to the | |
513 | .Ic -atime | |
514 | primary description for information on supported time units. | |
c0fcf4e1 A |
515 | .It Ic -name Ar pattern |
516 | True if the last component of the pathname being examined matches | |
517 | .Ar pattern . | |
518 | Special shell pattern matching characters | |
519 | .Dq ( Li \&[ , | |
520 | .Dq Li \&] , | |
521 | .Dq Li * , | |
522 | and | |
523 | .Dq Li \&? ) | |
524 | may be used as part of | |
525 | .Ar pattern . | |
526 | These characters may be matched explicitly by escaping them with a | |
527 | backslash | |
528 | .Pq Dq Li \e . | |
529 | .It Ic -newer Ar file | |
530 | True if the current file has a more recent last modification time than | |
531 | .Ar file . | |
532 | .It Ic -newer Ns Ar X Ns Ar Y Ar file | |
533 | True if the current file has a more recent last access time | |
534 | .Ar ( X Ns = Ns Cm a ) , | |
e1a085ba A |
535 | inode creation time |
536 | .Ar ( X Ns = Ns Cm B ) , | |
c0fcf4e1 A |
537 | change time |
538 | .Ar ( X Ns = Ns Cm c ) , | |
539 | or modification time | |
540 | .Ar ( X Ns = Ns Cm m ) | |
541 | than the last access time | |
542 | .Ar ( Y Ns = Ns Cm a ) , | |
e1a085ba A |
543 | inode creation time |
544 | .Ar ( Y Ns = Ns Cm B ) , | |
c0fcf4e1 A |
545 | change time |
546 | .Ar ( Y Ns = Ns Cm c ) , | |
547 | or modification time | |
548 | .Ar ( Y Ns = Ns Cm m ) | |
549 | of | |
550 | .Ar file . | |
551 | In addition, if | |
552 | .Ar Y Ns = Ns Cm t , | |
553 | then | |
554 | .Ar file | |
555 | is instead interpreted as a direct date specification of the form | |
556 | understood by | |
557 | .Xr cvs 1 . | |
558 | Note that | |
559 | .Ic -newermm | |
560 | is equivalent to | |
561 | .Ic -newer . | |
562 | .It Ic -nogroup | |
563 | True if the file belongs to an unknown group. | |
564 | .It Ic -nouser | |
565 | True if the file belongs to an unknown user. | |
e1a085ba | 566 | .It Ic -ok Ar utility Oo Ar argument ... Oc Li \&; |
44bd5ea7 | 567 | The |
c0fcf4e1 | 568 | .Ic -ok |
44bd5ea7 A |
569 | primary is identical to the |
570 | .Ic -exec | |
571 | primary with the exception that | |
572 | .Nm | |
c0fcf4e1 A |
573 | requests user affirmation for the execution of the |
574 | .Ar utility | |
575 | by printing | |
44bd5ea7 | 576 | a message to the terminal and reading a response. |
e1a085ba A |
577 | If the response is not affirmative |
578 | .Ql ( y | |
579 | in the | |
580 | .Dq Li POSIX | |
581 | locale), | |
c0fcf4e1 | 582 | the command is not executed and the |
44bd5ea7 | 583 | value of the |
c0fcf4e1 | 584 | .Ic -ok |
44bd5ea7 | 585 | expression is false. |
e1a085ba | 586 | .It Ic -okdir Ar utility Oo Ar argument ... Oc Li \&; |
c0fcf4e1 A |
587 | The |
588 | .Ic -okdir | |
589 | primary is identical to the | |
590 | .Ic -execdir | |
591 | primary with the same exception as described for the | |
592 | .Ic -ok | |
593 | primary. | |
594 | .It Ic -path Ar pattern | |
44bd5ea7 | 595 | True if the pathname being examined matches |
c0fcf4e1 A |
596 | .Ar pattern . |
597 | Special shell pattern matching characters | |
598 | .Dq ( Li \&[ , | |
599 | .Dq Li \&] , | |
600 | .Dq Li * , | |
601 | and | |
602 | .Dq Li \&? ) | |
44bd5ea7 | 603 | may be used as part of |
c0fcf4e1 | 604 | .Ar pattern . |
44bd5ea7 | 605 | These characters may be matched explicitly by escaping them with a |
c0fcf4e1 A |
606 | backslash |
607 | .Pq Dq Li \e . | |
608 | Slashes | |
609 | .Pq Dq Li / | |
610 | are treated as normal characters and do not have to be | |
44bd5ea7 | 611 | matched explicitly. |
c0fcf4e1 | 612 | .It Ic -perm Oo Cm - Ns | Ns Cm + Oc Ns Ar mode |
44bd5ea7 A |
613 | The |
614 | .Ar mode | |
615 | may be either symbolic (see | |
c0fcf4e1 | 616 | .Xr chmod 1 ) |
44bd5ea7 | 617 | or an octal number. |
c0fcf4e1 A |
618 | If the |
619 | .Ar mode | |
620 | is symbolic, a starting value of zero is assumed and the | |
621 | .Ar mode | |
622 | sets or clears permissions without regard to the process' file mode | |
44bd5ea7 | 623 | creation mask. |
c0fcf4e1 A |
624 | If the |
625 | .Ar mode | |
626 | is octal, only bits 07777 | |
627 | .Pq Dv S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO | |
44bd5ea7 A |
628 | of the file's mode bits participate |
629 | in the comparison. | |
c0fcf4e1 A |
630 | If the |
631 | .Ar mode | |
632 | is preceded by a dash | |
633 | .Pq Dq Li - , | |
634 | this primary evaluates to true | |
635 | if at least all of the bits in the | |
636 | .Ar mode | |
637 | are set in the file's mode bits. | |
638 | If the | |
639 | .Ar mode | |
640 | is preceded by a plus | |
641 | .Pq Dq Li + , | |
642 | this primary evaluates to true | |
643 | if any of the bits in the | |
644 | .Ar mode | |
645 | are set in the file's mode bits. | |
646 | Otherwise, this primary evaluates to true if | |
647 | the bits in the | |
648 | .Ar mode | |
649 | exactly match the file's mode bits. | |
650 | Note, the first character of a symbolic mode may not be a dash | |
651 | .Pq Dq Li - . | |
44bd5ea7 A |
652 | .It Ic -print |
653 | This primary always evaluates to true. | |
c0fcf4e1 | 654 | It prints the pathname of the current file to standard output. |
44bd5ea7 | 655 | If none of |
e1a085ba A |
656 | .\" 4772561 |
657 | .Ic -exec , -ls , -print , -print0 , | |
c0fcf4e1 A |
658 | or |
659 | .Ic -ok | |
44bd5ea7 | 660 | is specified, the given expression shall be effectively replaced by |
c0fcf4e1 | 661 | .Cm \&( Ar "given expression" Cm \&) Ic -print . |
44bd5ea7 A |
662 | .It Ic -print0 |
663 | This primary always evaluates to true. | |
c0fcf4e1 | 664 | It prints the pathname of the current file to standard output, followed by an |
e1a085ba A |
665 | .Tn ASCII |
666 | .Dv NUL | |
c0fcf4e1 | 667 | character (character code 0). |
44bd5ea7 A |
668 | .It Ic -prune |
669 | This primary always evaluates to true. | |
670 | It causes | |
671 | .Nm | |
672 | to not descend into the current file. | |
673 | Note, the | |
674 | .Ic -prune | |
675 | primary has no effect if the | |
676 | .Fl d | |
677 | option was specified. | |
c0fcf4e1 A |
678 | .It Ic -regex Ar pattern |
679 | True if the whole path of the file matches | |
680 | .Ar pattern | |
681 | using regular expression. | |
682 | To match a file named | |
683 | .Dq Pa ./foo/xyzzy , | |
684 | you can use the regular expression | |
685 | .Dq Li ".*/[xyz]*" | |
686 | or | |
687 | .Dq Li ".*/foo/.*" , | |
688 | but not | |
689 | .Dq Li xyzzy | |
690 | or | |
691 | .Dq Li /foo/ . | |
e1a085ba A |
692 | .It Ic -size Ar n Ns Op Cm ckMGTP |
693 | True if the file's size, rounded up, in 512-byte blocks is | |
c0fcf4e1 | 694 | .Ar n . |
44bd5ea7 A |
695 | If |
696 | .Ar n | |
c0fcf4e1 A |
697 | is followed by a |
698 | .Cm c , | |
699 | then the primary is true if the | |
44bd5ea7 A |
700 | file's size is |
701 | .Ar n | |
c0fcf4e1 | 702 | bytes (characters). |
e1a085ba A |
703 | Similarly if |
704 | .Ar n | |
705 | is followed by a scale indicator then the file's size is compared to | |
706 | .Ar n | |
707 | scaled as: | |
708 | .Pp | |
709 | .Bl -tag -width indent -compact | |
710 | .It Cm k | |
711 | kilobytes (1024 bytes) | |
712 | .It Cm M | |
713 | megabytes (1024 kilobytes) | |
714 | .It Cm G | |
715 | gigabytes (1024 megabytes) | |
716 | .It Cm T | |
717 | terabytes (1024 gigabytes) | |
718 | .It Cm P | |
719 | petabytes (1024 terabytes) | |
720 | .El | |
721 | .Pp | |
c0fcf4e1 | 722 | .It Ic -type Ar t |
44bd5ea7 A |
723 | True if the file is of the specified type. |
724 | Possible file types are as follows: | |
725 | .Pp | |
c0fcf4e1 | 726 | .Bl -tag -width indent -compact |
44bd5ea7 A |
727 | .It Cm b |
728 | block special | |
729 | .It Cm c | |
730 | character special | |
731 | .It Cm d | |
732 | directory | |
733 | .It Cm f | |
734 | regular file | |
735 | .It Cm l | |
736 | symbolic link | |
737 | .It Cm p | |
738 | FIFO | |
739 | .It Cm s | |
740 | socket | |
741 | .El | |
c0fcf4e1 | 742 | .It Ic -user Ar uname |
44bd5ea7 | 743 | True if the file belongs to the user |
c0fcf4e1 | 744 | .Ar uname . |
44bd5ea7 A |
745 | If |
746 | .Ar uname | |
747 | is numeric and there is no such user name, then | |
748 | .Ar uname | |
c0fcf4e1 | 749 | is treated as a user ID. |
44bd5ea7 A |
750 | .El |
751 | .Pp | |
752 | All primaries which take a numeric argument allow the number to be | |
c0fcf4e1 A |
753 | preceded by a plus sign |
754 | .Pq Dq Li + | |
755 | or a minus sign | |
756 | .Pq Dq Li - . | |
757 | A preceding plus sign means | |
758 | .Dq more than n , | |
759 | a preceding minus sign means | |
760 | .Dq less than n | |
761 | and neither means | |
762 | .Dq exactly n . | |
44bd5ea7 A |
763 | .Sh OPERATORS |
764 | The primaries may be combined using the following operators. | |
765 | The operators are listed in order of decreasing precedence. | |
c0fcf4e1 A |
766 | .Pp |
767 | .Bl -tag -width "( expression )" -compact | |
768 | .It Cm \&( Ar expression Cm \&) | |
44bd5ea7 A |
769 | This evaluates to true if the parenthesized expression evaluates to |
770 | true. | |
771 | .Pp | |
e1a085ba | 772 | .It Cm \&! Ar expression |
9bafe280 A |
773 | .It Cm -false Ar expression |
774 | .It Cm -not Ar expression | |
44bd5ea7 A |
775 | This is the unary |
776 | .Tn NOT | |
777 | operator. | |
778 | It evaluates to true if the expression is false. | |
779 | .Pp | |
c0fcf4e1 A |
780 | .It Ar expression Cm -and Ar expression |
781 | .It Ar expression expression | |
44bd5ea7 A |
782 | The |
783 | .Cm -and | |
784 | operator is the logical | |
785 | .Tn AND | |
786 | operator. | |
787 | As it is implied by the juxtaposition of two expressions it does not | |
788 | have to be specified. | |
789 | The expression evaluates to true if both expressions are true. | |
790 | The second expression is not evaluated if the first expression is false. | |
791 | .Pp | |
c0fcf4e1 | 792 | .It Ar expression Cm -or Ar expression |
44bd5ea7 A |
793 | The |
794 | .Cm -or | |
795 | operator is the logical | |
796 | .Tn OR | |
797 | operator. | |
798 | The expression evaluates to true if either the first or the second expression | |
799 | is true. | |
800 | The second expression is not evaluated if the first expression is true. | |
801 | .El | |
802 | .Pp | |
803 | All operands and primaries must be separate arguments to | |
c0fcf4e1 | 804 | .Nm . |
44bd5ea7 A |
805 | Primaries which themselves take arguments expect each argument |
806 | to be a separate argument to | |
c0fcf4e1 | 807 | .Nm . |
e1a085ba A |
808 | .Sh ENVIRONMENT |
809 | The | |
810 | .Ev LANG , LC_ALL , LC_COLLATE , LC_CTYPE , LC_MESSAGES | |
811 | and | |
812 | .Ev LC_TIME | |
813 | environment variables affect the execution of the | |
814 | .Nm | |
815 | utility as described in | |
816 | .Xr environ 7 . | |
44bd5ea7 | 817 | .Sh EXAMPLES |
44bd5ea7 | 818 | The following examples are shown as given to the shell: |
c0fcf4e1 A |
819 | .Bl -tag -width indent |
820 | .It Li "find / \e! -name \*q*.c\*q -print" | |
821 | Print out a list of all the files whose names do not end in | |
822 | .Pa .c . | |
823 | .It Li "find / -newer ttt -user wnj -print" | |
824 | Print out a list of all the files owned by user | |
825 | .Dq wnj | |
826 | that are newer | |
827 | than the file | |
828 | .Pa ttt . | |
829 | .It Li "find / \e! \e( -newer ttt -user wnj \e) -print" | |
830 | Print out a list of all the files which are not both newer than | |
831 | .Pa ttt | |
832 | and owned by | |
833 | .Dq wnj . | |
834 | .It Li "find / \e( -newer ttt -or -user wnj \e) -print" | |
835 | Print out a list of all the files that are either owned by | |
836 | .Dq wnj | |
837 | or that are newer than | |
838 | .Pa ttt . | |
e1a085ba | 839 | .It Li "find / -newerct '1 minute ago' -print" |
c0fcf4e1 A |
840 | Print out a list of all the files whose inode change time is more |
841 | recent than the current time minus one minute. | |
e1a085ba A |
842 | .It Li "find / -type f -exec echo {} \e;" |
843 | Use the | |
844 | .Xr echo 1 | |
845 | command to print out a list of all the files. | |
846 | .It Li "find -L /usr/ports/packages -type l -delete" | |
847 | Delete all broken symbolic links in | |
848 | .Pa /usr/ports/packages . | |
849 | .It Li "find /usr/src -name CVS -prune -o -depth +6 -print" | |
850 | Find files and directories that are at least seven levels deep | |
851 | in the working directory | |
852 | .Pa /usr/src . | |
853 | .It Li "find /usr/src -name CVS -prune -o -mindepth 7 -print" | |
854 | Is not equivalent to the previous example, since | |
855 | .Ic -prune | |
856 | is not evaluated below level seven. | |
44bd5ea7 | 857 | .El |
e1a085ba A |
858 | .Sh COMPATIBILITY |
859 | The | |
860 | .Ic -follow | |
861 | primary is deprecated; the | |
862 | .Fl L | |
863 | option should be used instead. | |
864 | See the | |
865 | .Sx STANDARDS | |
866 | section below for details. | |
44bd5ea7 | 867 | .Sh SEE ALSO |
c0fcf4e1 | 868 | .Xr chflags 1 , |
44bd5ea7 | 869 | .Xr chmod 1 , |
c0fcf4e1 | 870 | .Xr cvs 1 , |
44bd5ea7 | 871 | .Xr locate 1 , |
c0fcf4e1 A |
872 | .Xr whereis 1 , |
873 | .Xr which 1 , | |
e1a085ba | 874 | .Xr xargs 1 , |
44bd5ea7 | 875 | .Xr stat 2 , |
e1a085ba | 876 | .\" .Xr acl 3 , |
44bd5ea7 | 877 | .Xr fts 3 , |
44bd5ea7 | 878 | .Xr getgrent 3 , |
c0fcf4e1 | 879 | .Xr getpwent 3 , |
44bd5ea7 | 880 | .Xr strmode 3 , |
c0fcf4e1 | 881 | .Xr re_format 7 , |
44bd5ea7 A |
882 | .Xr symlink 7 |
883 | .Sh STANDARDS | |
884 | The | |
885 | .Nm | |
886 | utility syntax is a superset of the syntax specified by the | |
e1a085ba | 887 | .St -p1003.1-2001 |
44bd5ea7 A |
888 | standard. |
889 | .Pp | |
e1a085ba A |
890 | All the single character options except |
891 | .Ic -H | |
44bd5ea7 | 892 | and |
e1a085ba A |
893 | .Ic -L |
894 | as well as | |
895 | .Ic -amin , -anewer , -cmin , -cnewer , -delete , -empty , -fstype , | |
896 | .Ic -iname , -inum , -iregex , -ls , -maxdepth , -mindepth , -mmin , | |
897 | .Ic -path , -print0 , -regex | |
898 | and all of the | |
899 | .Ic -B | |
900 | birthtime related primaries are extensions to | |
901 | .St -p1003.1-2001 . | |
44bd5ea7 A |
902 | .Pp |
903 | Historically, the | |
e1a085ba | 904 | .Fl d , L |
44bd5ea7 A |
905 | and |
906 | .Fl x | |
c0fcf4e1 A |
907 | options were implemented using the primaries |
908 | .Ic -depth , -follow , | |
909 | and | |
910 | .Ic -xdev . | |
44bd5ea7 A |
911 | These primaries always evaluated to true. |
912 | As they were really global variables that took effect before the traversal | |
913 | began, some legal expressions could have unexpected results. | |
c0fcf4e1 A |
914 | An example is the expression |
915 | .Ic -print Cm -o Ic -depth . | |
916 | As | |
917 | .Ic -print | |
918 | always evaluates to true, the standard order of evaluation | |
919 | implies that | |
920 | .Ic -depth | |
921 | would never be evaluated. | |
44bd5ea7 A |
922 | This is not the case. |
923 | .Pp | |
c0fcf4e1 A |
924 | The operator |
925 | .Cm -or | |
926 | was implemented as | |
927 | .Cm -o , | |
928 | and the operator | |
929 | .Cm -and | |
930 | was implemented as | |
931 | .Cm -a . | |
44bd5ea7 A |
932 | .Pp |
933 | Historic implementations of the | |
934 | .Ic -exec | |
935 | and | |
936 | .Ic -ok | |
c0fcf4e1 A |
937 | primaries did not replace the string |
938 | .Dq Li {} | |
939 | in the utility name or the | |
44bd5ea7 A |
940 | utility arguments if it had preceding or following non-whitespace characters. |
941 | This version replaces it no matter where in the utility name or arguments | |
942 | it appears. | |
c0fcf4e1 A |
943 | .Pp |
944 | The | |
945 | .Fl E | |
e1a085ba | 946 | option was inspired by the equivalent |
c0fcf4e1 A |
947 | .Xr grep 1 |
948 | and | |
e1a085ba A |
949 | .Xr sed 1 |
950 | options. | |
951 | .Sh HISTORY | |
952 | A | |
953 | .Nm | |
954 | command appeared in | |
955 | .At v1 . | |
44bd5ea7 A |
956 | .Sh BUGS |
957 | The special characters used by | |
958 | .Nm | |
959 | are also special characters to many shell programs. | |
c0fcf4e1 A |
960 | In particular, the characters |
961 | .Dq Li * , | |
962 | .Dq Li \&[ , | |
963 | .Dq Li \&] , | |
964 | .Dq Li \&? , | |
965 | .Dq Li \&( , | |
966 | .Dq Li \&) , | |
967 | .Dq Li \&! , | |
968 | .Dq Li \e | |
969 | and | |
970 | .Dq Li \&; | |
971 | may have to be escaped from the shell. | |
44bd5ea7 A |
972 | .Pp |
973 | As there is no delimiter separating options and file names or file | |
974 | names and the | |
975 | .Ar expression , | |
c0fcf4e1 A |
976 | it is difficult to specify files named |
977 | .Pa -xdev | |
978 | or | |
979 | .Pa \&! . | |
44bd5ea7 A |
980 | These problems are handled by the |
981 | .Fl f | |
982 | option and the | |
983 | .Xr getopt 3 | |
c0fcf4e1 A |
984 | .Dq Fl Fl |
985 | construct. | |
986 | .Pp | |
987 | The | |
988 | .Ic -delete | |
e1a085ba | 989 | primary does not interact well with other options that cause the file system |
c0fcf4e1 | 990 | tree traversal options to be changed. |
e1a085ba A |
991 | .Pp |
992 | The | |
993 | .Ic -mindepth | |
994 | and | |
995 | .Ic -maxdepth | |
996 | primaries are actually global options (as documented above). | |
997 | They should | |
998 | probably be replaced by options which look like options. |