]>
Commit | Line | Data |
---|---|---|
44bd5ea7 A |
1 | .\" The Regents of the University of California. All rights reserved. |
2 | .\" | |
3 | .\" This code is derived from software contributed to Berkeley by | |
4 | .\" the Institute of Electrical and Electronics Engineers, Inc. | |
5 | .\" | |
6 | .\" Redistribution and use in source and binary forms, with or without | |
7 | .\" modification, are permitted provided that the following conditions | |
8 | .\" are met: | |
9 | .\" 1. Redistributions of source code must retain the above copyright | |
10 | .\" notice, this list of conditions and the following disclaimer. | |
11 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
12 | .\" notice, this list of conditions and the following disclaimer in the | |
13 | .\" documentation and/or other materials provided with the distribution. | |
14 | .\" 3. All advertising materials mentioning features or use of this software | |
15 | .\" must display the following acknowledgement: | |
16 | .\" This product includes software developed by the University of | |
17 | .\" California, Berkeley and its contributors. | |
18 | .\" 4. Neither the name of the University nor the names of its contributors | |
19 | .\" may be used to endorse or promote products derived from this software | |
20 | .\" without specific prior written permission. | |
21 | .\" | |
22 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
23 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
24 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
25 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
26 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
27 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
28 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
29 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
30 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
31 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
32 | .\" SUCH DAMAGE. | |
33 | .\" | |
c0fcf4e1 A |
34 | .\" @(#)find.1 8.7 (Berkeley) 5/9/95 |
35 | .\" $FreeBSD: src/usr.bin/find/find.1,v 1.23.2.14 2001/12/14 15:53:30 ru Exp $ | |
44bd5ea7 | 36 | .\" |
c0fcf4e1 | 37 | .Dd May 3, 2001 |
44bd5ea7 A |
38 | .Dt FIND 1 |
39 | .Os | |
40 | .Sh NAME | |
41 | .Nm find | |
42 | .Nd walk a file hierarchy | |
43 | .Sh SYNOPSIS | |
c0fcf4e1 | 44 | .Nm |
44bd5ea7 | 45 | .Op Fl H | Fl L | Fl P |
c0fcf4e1 A |
46 | .Op Fl EXdsx |
47 | .Op Fl f Ar pathname | |
48 | .Op Ar pathname ... | |
44bd5ea7 A |
49 | .Ar expression |
50 | .Sh DESCRIPTION | |
c0fcf4e1 | 51 | .Nm Find |
44bd5ea7 | 52 | recursively descends the directory tree for each |
c0fcf4e1 | 53 | .Ar pathname |
44bd5ea7 A |
54 | listed, evaluating an |
55 | .Ar expression | |
c0fcf4e1 A |
56 | (composed of the |
57 | .Dq primaries | |
58 | and | |
59 | .Dq operands | |
60 | listed below) in terms | |
44bd5ea7 A |
61 | of each file in the tree. |
62 | .Pp | |
63 | The options are as follows: | |
c0fcf4e1 A |
64 | .Bl -tag -width indent |
65 | .It Fl E | |
66 | Interpret regular expressions followed by | |
67 | .Ic -regex | |
68 | and | |
69 | .Ic -iregex | |
70 | options as extended (modern) regular expressions rather than basic | |
71 | regular expressions (BRE's). | |
72 | The | |
73 | .Xr re_format 7 | |
74 | manual page fully describes both formats. | |
44bd5ea7 A |
75 | .It Fl H |
76 | The | |
77 | .Fl H | |
78 | option causes the file information and file type (see | |
c0fcf4e1 A |
79 | .Xr stat 2 ) |
80 | returned for each symbolic link specified on the command line to be | |
44bd5ea7 A |
81 | those of the file referenced by the link, not the link itself. |
82 | If the referenced file does not exist, the file information and type will | |
c0fcf4e1 A |
83 | be for the link itself. |
84 | File information of all symbolic links not on | |
44bd5ea7 A |
85 | the command line is that of the link itself. |
86 | .It Fl L | |
87 | The | |
88 | .Fl L | |
89 | option causes the file information and file type (see | |
c0fcf4e1 | 90 | .Xr stat 2 ) |
44bd5ea7 A |
91 | returned for each symbolic link to be those of the file referenced by the |
92 | link, not the link itself. | |
93 | If the referenced file does not exist, the file information and type will | |
94 | be for the link itself. | |
95 | .It Fl P | |
96 | The | |
97 | .Fl P | |
98 | option causes the file information and file type (see | |
c0fcf4e1 | 99 | .Xr stat 2 ) |
44bd5ea7 | 100 | returned for each symbolic link to be those of the link itself. |
c0fcf4e1 | 101 | This is the default. |
44bd5ea7 A |
102 | .It Fl X |
103 | The | |
104 | .Fl X | |
105 | option is a modification to permit | |
106 | .Nm | |
107 | to be safely used in conjunction with | |
108 | .Xr xargs 1 . | |
109 | If a file name contains any of the delimiting characters used by | |
c0fcf4e1 | 110 | .Xr xargs 1 , |
44bd5ea7 A |
111 | a diagnostic message is displayed on standard error, and the file |
112 | is skipped. | |
c0fcf4e1 A |
113 | The delimiting characters include single |
114 | .Pq Dq Li " ' " | |
115 | and double | |
116 | .Pq Dq Li " \*q " | |
117 | quotes, backslash | |
118 | .Pq Dq Li \e , | |
119 | space, tab and newline characters. | |
44bd5ea7 A |
120 | .It Fl d |
121 | The | |
122 | .Fl d | |
123 | option causes | |
124 | .Nm | |
c0fcf4e1 | 125 | to perform a depth\-first traversal, i.e., directories |
44bd5ea7 A |
126 | are visited in post\-order and all entries in a directory will be acted |
127 | on before the directory itself. | |
128 | By default, | |
129 | .Nm | |
c0fcf4e1 | 130 | visits directories in pre\-order, i.e., before their contents. |
44bd5ea7 | 131 | Note, the default is |
c0fcf4e1 | 132 | .Em not |
44bd5ea7 A |
133 | a breadth\-first traversal. |
134 | .It Fl f | |
135 | The | |
136 | .Fl f | |
137 | option specifies a file hierarchy for | |
138 | .Nm | |
139 | to traverse. | |
140 | File hierarchies may also be specified as the operands immediately | |
141 | following the options. | |
c0fcf4e1 | 142 | .It Fl s |
44bd5ea7 | 143 | The |
c0fcf4e1 A |
144 | .Fl s |
145 | option causes | |
146 | .Nm | |
147 | to traverse the file hierarchies in lexicographical order, | |
148 | i.e., alphabetical order within each directory. | |
149 | Note: | |
150 | .Ql find -s | |
151 | and | |
152 | .Ql "find | sort" | |
153 | may give different results. | |
44bd5ea7 A |
154 | .It Fl x |
155 | The | |
156 | .Fl x | |
157 | option prevents | |
158 | .Nm | |
159 | from descending into directories that have a device number different | |
160 | than that of the file from which the descent began. | |
161 | .El | |
162 | .Sh PRIMARIES | |
c0fcf4e1 A |
163 | .Bl -tag -width indent |
164 | .It Ic -amin Ar n | |
165 | True if the difference between the file last access time and the time | |
166 | .Nm | |
167 | was started, rounded up to the next full minute, is | |
168 | .Ar n | |
169 | minutes. | |
170 | .It Ic -anewer Ar file | |
171 | Same as | |
172 | .Ic -neweram . | |
173 | .It Ic -atime Ar n | |
44bd5ea7 A |
174 | True if the difference between the file last access time and the time |
175 | .Nm | |
176 | was started, rounded up to the next full 24\-hour period, is | |
177 | .Ar n | |
178 | 24\-hour periods. | |
c0fcf4e1 A |
179 | .It Ic -cmin Ar n |
180 | True if the difference between the time of last change of file status | |
181 | information and the time | |
182 | .Nm | |
183 | was started, rounded up to the next full minute, is | |
184 | .Ar n | |
185 | minutes. | |
186 | .It Ic -cnewer Ar file | |
187 | Same as | |
188 | .Ic -newercm . | |
189 | .It Ic -ctime Ar n | |
44bd5ea7 A |
190 | True if the difference between the time of last change of file status |
191 | information and the time | |
192 | .Nm | |
193 | was started, rounded up to the next full 24\-hour period, is | |
194 | .Ar n | |
195 | 24\-hour periods. | |
c0fcf4e1 A |
196 | .It Ic -delete |
197 | Delete found files and/or directories. | |
198 | Always returns true. | |
199 | This executes | |
200 | from the current working directory as | |
201 | .Nm | |
202 | recurses down the tree. | |
203 | It will not attempt to delete a filename with a | |
204 | .Dq Pa / | |
205 | character in its pathname relative to | |
206 | .Dq Pa \&. | |
207 | for security reasons. | |
208 | Depth\-first traversal processing is implied by this option. | |
209 | .It Ic -depth | |
210 | Always true; | |
211 | same as the | |
212 | .Fl d | |
213 | option. | |
214 | .Ic -depth | |
215 | can be useful when | |
216 | .Nm | |
217 | is used with | |
218 | .Xr cpio 1 | |
219 | to process files that are contained in directories with unusual permissions. | |
220 | It enures that you have write permission while you are placing files in a | |
221 | directory, then sets the directory's permissions as the last thing. | |
222 | .It Ic -empty | |
223 | True if the current file or directory is empty. | |
224 | .It Ic -exec Ar utility Op Ar argument ... ; | |
44bd5ea7 A |
225 | True if the program named |
226 | .Ar utility | |
227 | returns a zero value as its exit status. | |
c0fcf4e1 A |
228 | Optional |
229 | .Ar arguments | |
230 | may be passed to the utility. | |
231 | The expression must be terminated by a semicolon | |
232 | .Pq Dq Li \&; . | |
233 | If the string | |
234 | .Dq Li {} | |
235 | appears anywhere in the utility name or the | |
44bd5ea7 A |
236 | arguments it is replaced by the pathname of the current file. |
237 | .Ar Utility | |
238 | will be executed from the directory from which | |
239 | .Nm | |
240 | was executed. | |
c0fcf4e1 A |
241 | .Ar Utility |
242 | and | |
243 | .Ar arguments | |
244 | are not subject to the further expansion of shell patterns | |
245 | and constructs. | |
246 | .It Ic -execdir Ar utility Op Ar argument ... ; | |
247 | The | |
248 | .Ic -execdir | |
249 | primary is identical to the | |
250 | .Ic -exec | |
251 | primary with the exception that | |
252 | .Ar utility | |
253 | will be executed from the directory that holds | |
254 | the current file. | |
255 | The filename substituted for | |
256 | the string | |
257 | .Dq Li {} | |
258 | is not qualified. | |
259 | .It Ic -flags Oo Cm - Ns | Ns Cm + Oc Ns Ar flags , Ns Ar notflags | |
260 | The flags are specified using symbolic names (see | |
261 | .Xr chflags 1 ) . | |
262 | Those with the | |
263 | .Qq Li no | |
264 | prefix (except | |
265 | .Qq Li nodump ) | |
266 | are said to be | |
267 | .Ar notflags . | |
268 | Flags in | |
269 | .Ar flags | |
270 | are checked to be set, and flags in | |
271 | .Ar notflags | |
272 | are checked to be not set. | |
273 | Note that this is different from | |
274 | .Ic -perm , | |
275 | which only allows the user to specify mode bits that are set. | |
276 | .Pp | |
277 | If flags are preceded by a dash | |
278 | .Pq Dq Li - , | |
279 | this primary evaluates to true | |
280 | if at least all of the bits in | |
281 | .Ar flags | |
282 | and none of the bits in | |
283 | .Ar notflags | |
284 | are set in the file's flags bits. | |
285 | If flags are preceded by a plus | |
286 | .Pq Dq Li + , | |
287 | this primary evaluates to true | |
288 | if any of the bits in | |
289 | .Ar flags | |
290 | is set in the file's flags bits, | |
291 | or any of the bits in | |
292 | .Ar notflags | |
293 | is not set in the file's flags bits. | |
294 | Otherwise, | |
295 | this primary evaluates to true | |
296 | if the bits in | |
297 | .Ar flags | |
298 | exactly match the file's flags bits, | |
299 | and none of the | |
300 | .Ar flags | |
301 | bits match those of | |
302 | .Ar notflags . | |
303 | .It Ic -fstype Ar type | |
44bd5ea7 A |
304 | True if the file is contained in a file system of type |
305 | .Ar type . | |
306 | The | |
307 | .Xr sysctl 8 | |
308 | command can be used to find out the types of filesystems | |
309 | that are available on the system: | |
c0fcf4e1 A |
310 | .Pp |
311 | .Dl "sysctl vfs" | |
312 | .Pp | |
313 | In addition, there are two pseudo-types, | |
314 | .Dq Li local | |
315 | and | |
316 | .Dq Li rdonly . | |
44bd5ea7 A |
317 | The former matches any file system physically mounted on the system where |
318 | the | |
319 | .Nm | |
c0fcf4e1 | 320 | is being executed and the latter matches any file system which is |
44bd5ea7 | 321 | mounted read-only. |
c0fcf4e1 | 322 | .It Ic -group Ar gname |
44bd5ea7 | 323 | True if the file belongs to the group |
c0fcf4e1 | 324 | .Ar gname . |
44bd5ea7 A |
325 | If |
326 | .Ar gname | |
327 | is numeric and there is no such group name, then | |
328 | .Ar gname | |
c0fcf4e1 A |
329 | is treated as a group ID. |
330 | .It Ic -iname Ar pattern | |
331 | Like | |
332 | .Ic -name , | |
333 | but the match is case insensitive. | |
334 | .It Ic -inum Ar n | |
44bd5ea7 | 335 | True if the file has inode number |
c0fcf4e1 A |
336 | .Ar n . |
337 | .It Ic -ipath Ar pattern | |
338 | Like | |
339 | .Ic -path , | |
340 | but the match is case insensitive. | |
341 | .It Ic -iregex Ar pattern | |
342 | Like | |
343 | .Ic -regex , | |
344 | but the match is case insensitive. | |
345 | .It Ic -links Ar n | |
44bd5ea7 A |
346 | True if the file has |
347 | .Ar n | |
348 | links. | |
349 | .It Ic -ls | |
350 | This primary always evaluates to true. | |
351 | The following information for the current file is written to standard output: | |
352 | its inode number, size in 512\-byte blocks, file permissions, number of hard | |
353 | links, owner, group, size in bytes, last modification time, and pathname. | |
354 | If the file is a block or character special file, the major and minor numbers | |
355 | will be displayed instead of the size in bytes. | |
356 | If the file is a symbolic link, the pathname of the linked\-to file will be | |
c0fcf4e1 A |
357 | displayed preceded by |
358 | .Dq Li -> . | |
359 | The format is identical to that produced by | |
360 | .Bk -words | |
361 | .Nm ls Fl dgils . | |
362 | .Ek | |
363 | .It Ic -maxdepth Ar n | |
364 | True if the depth of the current file into the tree is less than or equal to | |
365 | .Ar n . | |
366 | .It Ic -mindepth Ar n | |
367 | True if the depth of the current file into the tree is greater than or equal to | |
368 | .Ar n . | |
369 | .It Ic -mmin Ar n | |
370 | True if the difference between the file last modification time and the time | |
371 | .Nm | |
372 | was started, rounded up to the next full minute, is | |
373 | .Ar n | |
374 | minutes. | |
375 | .It Ic -mnewer Ar file | |
376 | Same as | |
377 | .Ic -newer . | |
378 | .It Ic -mtime Ar n | |
44bd5ea7 A |
379 | True if the difference between the file last modification time and the time |
380 | .Nm | |
381 | was started, rounded up to the next full 24\-hour period, is | |
382 | .Ar n | |
383 | 24\-hour periods. | |
c0fcf4e1 A |
384 | .It Ic -name Ar pattern |
385 | True if the last component of the pathname being examined matches | |
386 | .Ar pattern . | |
387 | Special shell pattern matching characters | |
388 | .Dq ( Li \&[ , | |
389 | .Dq Li \&] , | |
390 | .Dq Li * , | |
391 | and | |
392 | .Dq Li \&? ) | |
393 | may be used as part of | |
394 | .Ar pattern . | |
395 | These characters may be matched explicitly by escaping them with a | |
396 | backslash | |
397 | .Pq Dq Li \e . | |
398 | .It Ic -newer Ar file | |
399 | True if the current file has a more recent last modification time than | |
400 | .Ar file . | |
401 | .It Ic -newer Ns Ar X Ns Ar Y Ar file | |
402 | True if the current file has a more recent last access time | |
403 | .Ar ( X Ns = Ns Cm a ) , | |
404 | change time | |
405 | .Ar ( X Ns = Ns Cm c ) , | |
406 | or modification time | |
407 | .Ar ( X Ns = Ns Cm m ) | |
408 | than the last access time | |
409 | .Ar ( Y Ns = Ns Cm a ) , | |
410 | change time | |
411 | .Ar ( Y Ns = Ns Cm c ) , | |
412 | or modification time | |
413 | .Ar ( Y Ns = Ns Cm m ) | |
414 | of | |
415 | .Ar file . | |
416 | In addition, if | |
417 | .Ar Y Ns = Ns Cm t , | |
418 | then | |
419 | .Ar file | |
420 | is instead interpreted as a direct date specification of the form | |
421 | understood by | |
422 | .Xr cvs 1 . | |
423 | Note that | |
424 | .Ic -newermm | |
425 | is equivalent to | |
426 | .Ic -newer . | |
427 | .It Ic -nogroup | |
428 | True if the file belongs to an unknown group. | |
429 | .It Ic -nouser | |
430 | True if the file belongs to an unknown user. | |
431 | .It Ic -ok Ar utility Op Ar argument ... ; | |
44bd5ea7 | 432 | The |
c0fcf4e1 | 433 | .Ic -ok |
44bd5ea7 A |
434 | primary is identical to the |
435 | .Ic -exec | |
436 | primary with the exception that | |
437 | .Nm | |
c0fcf4e1 A |
438 | requests user affirmation for the execution of the |
439 | .Ar utility | |
440 | by printing | |
44bd5ea7 | 441 | a message to the terminal and reading a response. |
c0fcf4e1 A |
442 | If the response is other than |
443 | .Dq Li y | |
444 | the command is not executed and the | |
44bd5ea7 | 445 | value of the |
c0fcf4e1 | 446 | .Ic -ok |
44bd5ea7 | 447 | expression is false. |
c0fcf4e1 A |
448 | .It Ic -okdir Ar utility Op Ar argument ... ; |
449 | The | |
450 | .Ic -okdir | |
451 | primary is identical to the | |
452 | .Ic -execdir | |
453 | primary with the same exception as described for the | |
454 | .Ic -ok | |
455 | primary. | |
456 | .It Ic -path Ar pattern | |
44bd5ea7 | 457 | True if the pathname being examined matches |
c0fcf4e1 A |
458 | .Ar pattern . |
459 | Special shell pattern matching characters | |
460 | .Dq ( Li \&[ , | |
461 | .Dq Li \&] , | |
462 | .Dq Li * , | |
463 | and | |
464 | .Dq Li \&? ) | |
44bd5ea7 | 465 | may be used as part of |
c0fcf4e1 | 466 | .Ar pattern . |
44bd5ea7 | 467 | These characters may be matched explicitly by escaping them with a |
c0fcf4e1 A |
468 | backslash |
469 | .Pq Dq Li \e . | |
470 | Slashes | |
471 | .Pq Dq Li / | |
472 | are treated as normal characters and do not have to be | |
44bd5ea7 | 473 | matched explicitly. |
c0fcf4e1 | 474 | .It Ic -perm Oo Cm - Ns | Ns Cm + Oc Ns Ar mode |
44bd5ea7 A |
475 | The |
476 | .Ar mode | |
477 | may be either symbolic (see | |
c0fcf4e1 | 478 | .Xr chmod 1 ) |
44bd5ea7 | 479 | or an octal number. |
c0fcf4e1 A |
480 | If the |
481 | .Ar mode | |
482 | is symbolic, a starting value of zero is assumed and the | |
483 | .Ar mode | |
484 | sets or clears permissions without regard to the process' file mode | |
44bd5ea7 | 485 | creation mask. |
c0fcf4e1 A |
486 | If the |
487 | .Ar mode | |
488 | is octal, only bits 07777 | |
489 | .Pq Dv S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO | |
44bd5ea7 A |
490 | of the file's mode bits participate |
491 | in the comparison. | |
c0fcf4e1 A |
492 | If the |
493 | .Ar mode | |
494 | is preceded by a dash | |
495 | .Pq Dq Li - , | |
496 | this primary evaluates to true | |
497 | if at least all of the bits in the | |
498 | .Ar mode | |
499 | are set in the file's mode bits. | |
500 | If the | |
501 | .Ar mode | |
502 | is preceded by a plus | |
503 | .Pq Dq Li + , | |
504 | this primary evaluates to true | |
505 | if any of the bits in the | |
506 | .Ar mode | |
507 | are set in the file's mode bits. | |
508 | Otherwise, this primary evaluates to true if | |
509 | the bits in the | |
510 | .Ar mode | |
511 | exactly match the file's mode bits. | |
512 | Note, the first character of a symbolic mode may not be a dash | |
513 | .Pq Dq Li - . | |
44bd5ea7 A |
514 | .It Ic -print |
515 | This primary always evaluates to true. | |
c0fcf4e1 | 516 | It prints the pathname of the current file to standard output. |
44bd5ea7 | 517 | If none of |
c0fcf4e1 A |
518 | .Ic -exec , -ls , -print0 , |
519 | or | |
520 | .Ic -ok | |
44bd5ea7 | 521 | is specified, the given expression shall be effectively replaced by |
c0fcf4e1 | 522 | .Cm \&( Ar "given expression" Cm \&) Ic -print . |
44bd5ea7 A |
523 | .It Ic -print0 |
524 | This primary always evaluates to true. | |
c0fcf4e1 A |
525 | It prints the pathname of the current file to standard output, followed by an |
526 | .Tn ASCII NUL | |
527 | character (character code 0). | |
44bd5ea7 A |
528 | .It Ic -prune |
529 | This primary always evaluates to true. | |
530 | It causes | |
531 | .Nm | |
532 | to not descend into the current file. | |
533 | Note, the | |
534 | .Ic -prune | |
535 | primary has no effect if the | |
536 | .Fl d | |
537 | option was specified. | |
c0fcf4e1 A |
538 | .It Ic -regex Ar pattern |
539 | True if the whole path of the file matches | |
540 | .Ar pattern | |
541 | using regular expression. | |
542 | To match a file named | |
543 | .Dq Pa ./foo/xyzzy , | |
544 | you can use the regular expression | |
545 | .Dq Li ".*/[xyz]*" | |
546 | or | |
547 | .Dq Li ".*/foo/.*" , | |
548 | but not | |
549 | .Dq Li xyzzy | |
550 | or | |
551 | .Dq Li /foo/ . | |
552 | .It Ic -size Ar n Ns Op Cm c | |
44bd5ea7 | 553 | True if the file's size, rounded up, in 512\-byte blocks is |
c0fcf4e1 | 554 | .Ar n . |
44bd5ea7 A |
555 | If |
556 | .Ar n | |
c0fcf4e1 A |
557 | is followed by a |
558 | .Cm c , | |
559 | then the primary is true if the | |
44bd5ea7 A |
560 | file's size is |
561 | .Ar n | |
c0fcf4e1 A |
562 | bytes (characters). |
563 | .It Ic -type Ar t | |
44bd5ea7 A |
564 | True if the file is of the specified type. |
565 | Possible file types are as follows: | |
566 | .Pp | |
c0fcf4e1 | 567 | .Bl -tag -width indent -compact |
44bd5ea7 A |
568 | .It Cm b |
569 | block special | |
570 | .It Cm c | |
571 | character special | |
572 | .It Cm d | |
573 | directory | |
574 | .It Cm f | |
575 | regular file | |
576 | .It Cm l | |
577 | symbolic link | |
578 | .It Cm p | |
579 | FIFO | |
580 | .It Cm s | |
581 | socket | |
582 | .El | |
c0fcf4e1 | 583 | .It Ic -user Ar uname |
44bd5ea7 | 584 | True if the file belongs to the user |
c0fcf4e1 | 585 | .Ar uname . |
44bd5ea7 A |
586 | If |
587 | .Ar uname | |
588 | is numeric and there is no such user name, then | |
589 | .Ar uname | |
c0fcf4e1 | 590 | is treated as a user ID. |
44bd5ea7 A |
591 | .El |
592 | .Pp | |
593 | All primaries which take a numeric argument allow the number to be | |
c0fcf4e1 A |
594 | preceded by a plus sign |
595 | .Pq Dq Li + | |
596 | or a minus sign | |
597 | .Pq Dq Li - . | |
598 | A preceding plus sign means | |
599 | .Dq more than n , | |
600 | a preceding minus sign means | |
601 | .Dq less than n | |
602 | and neither means | |
603 | .Dq exactly n . | |
44bd5ea7 A |
604 | .Sh OPERATORS |
605 | The primaries may be combined using the following operators. | |
606 | The operators are listed in order of decreasing precedence. | |
c0fcf4e1 A |
607 | .Pp |
608 | .Bl -tag -width "( expression )" -compact | |
609 | .It Cm \&( Ar expression Cm \&) | |
44bd5ea7 A |
610 | This evaluates to true if the parenthesized expression evaluates to |
611 | true. | |
612 | .Pp | |
9bafe280 A |
613 | .It Cm \&! Ar expression |
614 | .It Cm -false Ar expression | |
615 | .It Cm -not Ar expression | |
44bd5ea7 A |
616 | This is the unary |
617 | .Tn NOT | |
618 | operator. | |
619 | It evaluates to true if the expression is false. | |
620 | .Pp | |
c0fcf4e1 A |
621 | .It Ar expression Cm -and Ar expression |
622 | .It Ar expression expression | |
44bd5ea7 A |
623 | The |
624 | .Cm -and | |
625 | operator is the logical | |
626 | .Tn AND | |
627 | operator. | |
628 | As it is implied by the juxtaposition of two expressions it does not | |
629 | have to be specified. | |
630 | The expression evaluates to true if both expressions are true. | |
631 | The second expression is not evaluated if the first expression is false. | |
632 | .Pp | |
c0fcf4e1 | 633 | .It Ar expression Cm -or Ar expression |
44bd5ea7 A |
634 | The |
635 | .Cm -or | |
636 | operator is the logical | |
637 | .Tn OR | |
638 | operator. | |
639 | The expression evaluates to true if either the first or the second expression | |
640 | is true. | |
641 | The second expression is not evaluated if the first expression is true. | |
642 | .El | |
643 | .Pp | |
644 | All operands and primaries must be separate arguments to | |
c0fcf4e1 | 645 | .Nm . |
44bd5ea7 A |
646 | Primaries which themselves take arguments expect each argument |
647 | to be a separate argument to | |
c0fcf4e1 | 648 | .Nm . |
44bd5ea7 | 649 | .Sh EXAMPLES |
44bd5ea7 | 650 | The following examples are shown as given to the shell: |
c0fcf4e1 A |
651 | .Bl -tag -width indent |
652 | .It Li "find / \e! -name \*q*.c\*q -print" | |
653 | Print out a list of all the files whose names do not end in | |
654 | .Pa .c . | |
655 | .It Li "find / -newer ttt -user wnj -print" | |
656 | Print out a list of all the files owned by user | |
657 | .Dq wnj | |
658 | that are newer | |
659 | than the file | |
660 | .Pa ttt . | |
661 | .It Li "find / \e! \e( -newer ttt -user wnj \e) -print" | |
662 | Print out a list of all the files which are not both newer than | |
663 | .Pa ttt | |
664 | and owned by | |
665 | .Dq wnj . | |
666 | .It Li "find / \e( -newer ttt -or -user wnj \e) -print" | |
667 | Print out a list of all the files that are either owned by | |
668 | .Dq wnj | |
669 | or that are newer than | |
670 | .Pa ttt . | |
671 | .It Li "find . -newerct '1 minute ago' -print" | |
672 | Print out a list of all the files whose inode change time is more | |
673 | recent than the current time minus one minute. | |
44bd5ea7 A |
674 | .El |
675 | .Sh SEE ALSO | |
c0fcf4e1 | 676 | .Xr chflags 1 , |
44bd5ea7 | 677 | .Xr chmod 1 , |
c0fcf4e1 | 678 | .Xr cvs 1 , |
44bd5ea7 | 679 | .Xr locate 1 , |
c0fcf4e1 A |
680 | .Xr whereis 1 , |
681 | .Xr which 1 , | |
44bd5ea7 A |
682 | .Xr stat 2 , |
683 | .Xr fts 3 , | |
44bd5ea7 | 684 | .Xr getgrent 3 , |
c0fcf4e1 | 685 | .Xr getpwent 3 , |
44bd5ea7 | 686 | .Xr strmode 3 , |
c0fcf4e1 | 687 | .Xr re_format 7 , |
44bd5ea7 A |
688 | .Xr symlink 7 |
689 | .Sh STANDARDS | |
690 | The | |
691 | .Nm | |
692 | utility syntax is a superset of the syntax specified by the | |
693 | .St -p1003.2 | |
694 | standard. | |
695 | .Pp | |
c0fcf4e1 A |
696 | All the single character options as well as the |
697 | .Ic -iname , -inum , -iregex , -print0 , -delete , -ls , | |
44bd5ea7 | 698 | and |
c0fcf4e1 | 699 | .Ic -regex |
44bd5ea7 A |
700 | primaries are extensions to |
701 | .St -p1003.2 . | |
702 | .Pp | |
703 | Historically, the | |
c0fcf4e1 | 704 | .Fl d , h |
44bd5ea7 A |
705 | and |
706 | .Fl x | |
c0fcf4e1 A |
707 | options were implemented using the primaries |
708 | .Ic -depth , -follow , | |
709 | and | |
710 | .Ic -xdev . | |
44bd5ea7 A |
711 | These primaries always evaluated to true. |
712 | As they were really global variables that took effect before the traversal | |
713 | began, some legal expressions could have unexpected results. | |
c0fcf4e1 A |
714 | An example is the expression |
715 | .Ic -print Cm -o Ic -depth . | |
716 | As | |
717 | .Ic -print | |
718 | always evaluates to true, the standard order of evaluation | |
719 | implies that | |
720 | .Ic -depth | |
721 | would never be evaluated. | |
44bd5ea7 A |
722 | This is not the case. |
723 | .Pp | |
c0fcf4e1 A |
724 | The operator |
725 | .Cm -or | |
726 | was implemented as | |
727 | .Cm -o , | |
728 | and the operator | |
729 | .Cm -and | |
730 | was implemented as | |
731 | .Cm -a . | |
44bd5ea7 A |
732 | .Pp |
733 | Historic implementations of the | |
734 | .Ic -exec | |
735 | and | |
736 | .Ic -ok | |
c0fcf4e1 A |
737 | primaries did not replace the string |
738 | .Dq Li {} | |
739 | in the utility name or the | |
44bd5ea7 A |
740 | utility arguments if it had preceding or following non-whitespace characters. |
741 | This version replaces it no matter where in the utility name or arguments | |
742 | it appears. | |
c0fcf4e1 A |
743 | .Pp |
744 | The | |
745 | .Fl E | |
746 | option was implemented on the analogy of | |
747 | .Xr grep 1 | |
748 | and | |
749 | .Xr sed 1 . | |
44bd5ea7 A |
750 | .Sh BUGS |
751 | The special characters used by | |
752 | .Nm | |
753 | are also special characters to many shell programs. | |
c0fcf4e1 A |
754 | In particular, the characters |
755 | .Dq Li * , | |
756 | .Dq Li \&[ , | |
757 | .Dq Li \&] , | |
758 | .Dq Li \&? , | |
759 | .Dq Li \&( , | |
760 | .Dq Li \&) , | |
761 | .Dq Li \&! , | |
762 | .Dq Li \e | |
763 | and | |
764 | .Dq Li \&; | |
765 | may have to be escaped from the shell. | |
44bd5ea7 A |
766 | .Pp |
767 | As there is no delimiter separating options and file names or file | |
768 | names and the | |
769 | .Ar expression , | |
c0fcf4e1 A |
770 | it is difficult to specify files named |
771 | .Pa -xdev | |
772 | or | |
773 | .Pa \&! . | |
44bd5ea7 A |
774 | These problems are handled by the |
775 | .Fl f | |
776 | option and the | |
777 | .Xr getopt 3 | |
c0fcf4e1 A |
778 | .Dq Fl Fl |
779 | construct. | |
780 | .Pp | |
781 | The | |
782 | .Ic -delete | |
783 | primary does not interact well with other options that cause the filesystem | |
784 | tree traversal options to be changed. | |
785 | .Sh HISTORY | |
786 | A | |
787 | .Nm | |
788 | command appeared in | |
789 | .At v1 . |