1 '\" te 2 .\" Copyright 1989 AT&T 3 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved 4 .\" Copyright 2011 Nexenta Systems, Inc. All rights reserved. 5 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved 6 .\" 7 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for 8 .\" permission to reproduce portions of its copyrighted documentation. 9 .\" Original documentation from The Open Group can be obtained online at 10 .\" http://www.opengroup.org/bookstore/. 11 .\" The Institute of Electrical and Electronics Engineers and The Open Group, 12 .\" have given us permission to reprint portions of their documentation. 13 .\" In the following statement, the phrase "this text" refers to portions of 14 .\" the system documentation. Portions of this text are reprinted and 15 .\" reproduced in electronic form in the Sun OS Reference Manual, from 16 .\" IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- 17 .\" Portable Operating System Interface (POSIX), The Open Group Base 18 .\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of 19 .\" Electrical and Electronics Engineers, Inc and The Open Group. In the event 20 .\" of any discrepancy between these versions and the original IEEE and 21 .\" The Open Group Standard, the original IEEE and The Open Group Standard 22 .\" is the referee document. The original Standard can be obtained online 23 .\" at http://www.opengroup.org/unix/online.html. 24 .\" This notice shall appear on any product containing this material. 25 .\" The contents of this file are subject to the terms of the Common Development 26 .\" and Distribution License (the "License"). You may not use this file except 27 .\" in compliance with the License. 28 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or 29 .\" http://www.opensolaris.org/os/licensing. See the License for the specific 30 .\" language governing permissions and limitations under the License. 31 .\" When distributing Covered Code, include this CDDL HEADER in each file and 32 .\" include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, 33 .\" add the following below this CDDL HEADER, with the fields enclosed by 34 .\" brackets "[]" replaced with your own identifying information: 35 .\" Portions Copyright [yyyy] [name of copyright owner] 36 .TH FIND 1 "Sep 5, 2011" 37 .SH NAME 38 find \- find files 39 .SH SYNOPSIS 40 .LP 41 .nf 42 \fB/usr/bin/find\fR [\fB-E\fR] [\fB-H\fR | \fB-L\fR] \fIpath\fR... \fIexpression\fR 43 .fi 44 45 .LP 46 .nf 47 \fB/usr/xpg4/bin/find\fR [\fB-H\fR | \fB-L\fR] \fIpath\fR... \fIexpression\fR 48 .fi 49 50 .SH DESCRIPTION 51 .sp 52 .LP 53 The \fBfind\fR utility recursively descends the directory hierarchy for each 54 \fIpath\fR seeking files that match a Boolean \fIexpression\fR written in the 55 primaries specified below. 56 .sp 57 .LP 58 \fBfind\fR is able to descend to arbitrary depths in a file hierarchy and does 59 not fail due to path length limitations (unless a \fIpath\fR operand specified 60 by the application exceeds \fIPATH_MAX\fR requirements). 61 .sp 62 .LP 63 \fBfind\fR detects infinite loops; that is, entering a previously visited 64 directory that is an ancestor of the last file encountered. 65 .SH OPTIONS 66 .sp 67 .LP 68 The following options are supported: 69 .sp 70 .ne 2 71 .na 72 \fB\fB-E\fR\fR 73 .ad 74 .RS 6n 75 Interpret regular expressions followed by \fB-regex\fR and \fB-iregex\fR 76 primaries as extended regular expressions. 77 .RE 78 79 .sp 80 .ne 2 81 .na 82 \fB\fB-H\fR\fR 83 .ad 84 .RS 6n 85 Causes the file information and file type evaluated for each symbolic link 86 encountered on the command line to be those of the file referenced by the link, 87 and not the link itself. If the referenced file does not exist, the file 88 information and type is for the link itself. File information for all symbolic 89 links not on the command line is that of the link itself. 90 .RE 91 92 .sp 93 .ne 2 94 .na 95 \fB\fB-L\fR\fR 96 .ad 97 .RS 6n 98 Causes the file information and file type evaluated for each symbolic link to 99 be those of the file referenced by the link, and not the link itself. See 100 \fBNOTES\fR. 101 .RE 102 103 .sp 104 .LP 105 Specifying more than one of the mutually-exclusive options \fB-H\fR and 106 \fB-L\fR is not considered an error. The last option specified determines the 107 behavior of the utility. 108 .SH OPERANDS 109 .sp 110 .LP 111 The following operands are supported: 112 .sp 113 .ne 2 114 .na 115 \fB\fIpath\fR\fR 116 .ad 117 .RS 14n 118 A pathname of a starting point in the directory hierarchy. 119 .RE 120 121 .sp 122 .ne 2 123 .na 124 \fB\fIexpression\fR\fR 125 .ad 126 .RS 14n 127 The first argument that starts with a \fB\(mi\fR, or is a \fB!\fR or a \fB(\fR, 128 and all subsequent arguments are interpreted as an \fIexpression\fR made up of 129 the following primaries and operators. In the descriptions, wherever \fIn\fR is 130 used as a primary argument, it is interpreted as a decimal integer optionally 131 preceded by a plus (\fB+\fR) or minus (\fB\(mi\fR) sign, as follows: 132 .sp 133 .ne 2 134 .na 135 \fB+\fIn\fR\fR 136 .ad 137 .RS 6n 138 more than \fIn\fR 139 .RE 140 141 .sp 142 .ne 2 143 .na 144 \fB\fIn\fR\fR 145 .ad 146 .RS 6n 147 exactly \fIn\fR 148 .RE 149 150 .sp 151 .ne 2 152 .na 153 \fB-\fIn\fR\fR 154 .ad 155 .RS 6n 156 less than \fIn\fR 157 .RE 158 159 .RE 160 161 .SS "Expressions" 162 .sp 163 .LP 164 Valid expressions are: 165 .sp 166 .ne 2 167 .na 168 \fB\fB-acl\fR\fR 169 .ad 170 .RS 17n 171 True if the file have additional ACLs defined. 172 .RE 173 174 .sp 175 .ne 2 176 .na 177 \fB\fB-amin\fR \fIn\fR\fR 178 .ad 179 .RS 17n 180 File was last accessed \fIn\fR minutes ago. 181 .RE 182 183 .sp 184 .ne 2 185 .na 186 \fB\fB-atime\fR \fIn\fR\fR 187 .ad 188 .RS 17n 189 True if the file was accessed \fIn\fR days ago. The access time of directories 190 in \fIpath\fR is changed by \fBfind\fR itself. 191 .RE 192 193 .sp 194 .ne 2 195 .na 196 \fB\fB-cmin\fR \fIn\fR\fR 197 .ad 198 .RS 17n 199 File's status was last changed \fIn\fR minutes ago. 200 .RE 201 202 .sp 203 .ne 2 204 .na 205 \fB\fB-cpio\fR \fIdevice\fR\fR 206 .ad 207 .RS 17n 208 Always true. Writes the current file on \fIdevice\fR in \fBcpio\fR format 209 (5120-byte records). 210 .RE 211 212 .sp 213 .ne 2 214 .na 215 \fB\fB-ctime\fR \fIn\fR\fR 216 .ad 217 .RS 17n 218 True if the file's status was changed \fIn\fR days ago. 219 .RE 220 221 .sp 222 .ne 2 223 .na 224 \fB\fB-depth\fR\fR 225 .ad 226 .RS 17n 227 Always true. Causes descent of the directory hierarchy to be done so that all 228 entries in a directory are acted on before the directory itself. This can be 229 useful when \fBfind\fR is used with \fBcpio\fR(1) to transfer files that are 230 contained in directories without write permission. 231 .RE 232 233 .sp 234 .ne 2 235 .na 236 \fB\fB-exec\fR \fIcommand\fR\fR 237 .ad 238 .RS 17n 239 True if the executed command returns a zero value as exit status. The end of 240 command must be punctuated by an escaped semicolon (\fB;\fR). A command 241 argument \fB{}\fR is replaced by the current pathname. If the last argument to 242 \fB-exec\fR is \fB{}\fR and you specify \fB+\fR rather than the semicolon 243 (\fB;\fR), the command is invoked fewer times, with \fB{}\fR replaced by groups 244 of pathnames. If any invocation of the command returns a non-zero value as exit 245 status, find returns a non-zero exit status. 246 .RE 247 248 .sp 249 .ne 2 250 .na 251 \fB\fB-follow\fR\fR 252 .ad 253 .RS 17n 254 Always true and always evaluated no matter where it appears in 255 \fIexpression\fR. The behavior is unspecified if \fB-follow\fR is used when the 256 \fBfind\fR command is invoked with either the \fB-H\fR or the \fB-L\fR option. 257 Causes symbolic links to be followed. When following symbolic links, \fBfind\fR 258 keeps track of the directories visited so that it can detect infinite loops. 259 For example, such a loop would occur if a symbolic link pointed to an ancestor. 260 This expression should not be used with the find-type \fBl\fR expression. See 261 \fBNOTES\fR. 262 .RE 263 264 .sp 265 .ne 2 266 .na 267 \fB\fB-fstype\fR \fItype\fR\fR 268 .ad 269 .RS 17n 270 True if the filesystem to which the file belongs is of type \fItype\fR. 271 .RE 272 273 .sp 274 .ne 2 275 .na 276 \fB\fB-group\fR \fIgname\fR\fR 277 .ad 278 .RS 17n 279 True if the file belongs to the group \fIgname\fR. If \fIgname\fR is numeric 280 and there's no such group name, it is taken as a group \fBID\fR. 281 .RE 282 283 .sp 284 .ne 2 285 .na 286 \fB\fB-groupacl\fR \fIgname\fR\fR 287 .ad 288 .RS 17n 289 True if the file's ACL contains an entry for the group \fIgname\fR. 290 If \fIgname\fR is numeric and there's no such group name, it is taken 291 as a group \fBID\fR. 292 .RE 293 294 .sp 295 .ne 2 296 .na 297 \fB\fB-iname\fR \fIpattern\fR\fR 298 .ad 299 .RS 17n 300 Like \fB-name\fR, but the match is case insensitive. 301 .RE 302 303 .sp 304 .ne 2 305 .na 306 \fB\fB-inum\fR \fIn\fR\fR 307 .ad 308 .RS 17n 309 True if the file has inode number \fIn\fR. 310 .RE 311 312 .sp 313 .ne 2 314 .na 315 \fB\fB-iregex\fR \fIpattern\fR\fR 316 .ad 317 .RS 17n 318 Like \fB-regex\fR, but the match is case insensitive. 319 .RE 320 321 .sp 322 .ne 2 323 .na 324 \fB\fB-links\fR \fIn\fR\fR 325 .ad 326 .RS 17n 327 True if the file has \fIn\fR links. 328 .RE 329 330 .sp 331 .ne 2 332 .na 333 \fB\fB-local\fR\fR 334 .ad 335 .RS 17n 336 True if the file system type is not a remote file system type as defined in the 337 \fB/etc/dfs/fstypes\fR file. \fBnfs\fR is used as the default remote filesystem 338 type if the \fB/etc/dfs/fstypes\fR file is not present. The \fB-local\fR option 339 descends the hierarchy of non-local directories. See \fBEXAMPLES\fR for an 340 example of how to search for local files without descending. 341 .RE 342 343 .sp 344 .ne 2 345 .na 346 \fB\fB-ls\fR\fR 347 .ad 348 .RS 17n 349 Always true. Prints current pathname together with its associated statistics. 350 These include (respectively): 351 .RS +4 352 .TP 353 .ie t \(bu 354 .el o 355 inode number 356 .RE 357 .RS +4 358 .TP 359 .ie t \(bu 360 .el o 361 size in kilobytes (1024 bytes) 362 .RE 363 .RS +4 364 .TP 365 .ie t \(bu 366 .el o 367 protection mode 368 .RE 369 .RS +4 370 .TP 371 .ie t \(bu 372 .el o 373 number of hard links 374 .RE 375 .RS +4 376 .TP 377 .ie t \(bu 378 .el o 379 user 380 .RE 381 .RS +4 382 .TP 383 .ie t \(bu 384 .el o 385 group 386 .RE 387 .RS +4 388 .TP 389 .ie t \(bu 390 .el o 391 size in bytes 392 .RE 393 .RS +4 394 .TP 395 .ie t \(bu 396 .el o 397 modification time. 398 .RE 399 If the file is a special file, the size field instead contains the major and 400 minor device numbers. 401 .sp 402 If the file is a symbolic link, the pathname of the linked-to file is printed 403 preceded by `\fB\(->\fR\&'. The format is identical to that of \fBls\fR 404 \fB-gilds\fR (see \fBls\fR(1B)). 405 .sp 406 Formatting is done internally, without executing the \fBls\fR program. 407 .RE 408 409 .sp 410 .ne 2 411 .na 412 \fB\fB-maxdepth\fR \fIn\fR\fR 413 .ad 414 .RS 17n 415 Always true; descend at most \fIn\fR directory levels below the command 416 line arguments. If any \fB-maxdepth\fR primary is specified, it 417 applies to the entire expression even if it would not normally be 418 evaluated. \fB-maxdepth 0\fR limits the whole search to 419 the command line arguments. 420 .RE 421 422 .sp 423 .ne 2 424 .na 425 \fB\fB-mindepth\fR \fIn\fR\fR 426 .ad 427 .RS 17n 428 Always true; do not apply any tests or actions at levels less 429 than \fIn\fR. If any \fB-mindepth\fR primary is specified, it applies to the 430 entire expression even if it would not normally be evaluated. 431 \fB-mindepth 1\fR processes all but the command line arguments. 432 .RE 433 434 .sp 435 .ne 2 436 .na 437 \fB\fB-mmin\fR \fIn\fR\fR 438 .ad 439 .RS 17n 440 File's data was last modified \fIn\fR minutes ago. 441 .RE 442 443 .sp 444 .ne 2 445 .na 446 \fB\fB-mount\fR\fR 447 .ad 448 .RS 17n 449 Always true. Restricts the search to the file system containing the directory 450 specified. Does not list mount points to other file systems. 451 .RE 452 453 .sp 454 .ne 2 455 .na 456 \fB\fB-mtime\fR \fIn\fR\fR 457 .ad 458 .RS 17n 459 True if the file's data was modified \fIn\fR days ago. 460 .RE 461 462 .sp 463 .ne 2 464 .na 465 \fB\fB-name\fR \fIpattern\fR\fR 466 .ad 467 .RS 17n 468 True if \fIpattern\fR matches the basename of the current file name. Normal 469 shell file name generation characters (see \fBsh\fR(1)) can be used. A 470 backslash (\fB\|\e\|\fR) is used as an escape character within the pattern. The 471 pattern should be escaped or quoted when \fBfind\fR is invoked from the shell. 472 .sp 473 Unless the character '\fB\&.\fR' is explicitly specified in the beginning of 474 \fIpattern\fR, a current file name beginning with '\fB\&.\fR' does not match 475 \fIpattern\fR when using \fB/usr/bin/find\fR. \fB/usr/xpg4/bin/find\fR does not 476 make this distinction; wildcard file name generation characters can match file 477 names beginning with '\fB\&.\fR'. 478 .RE 479 480 .sp 481 .ne 2 482 .na 483 \fB\fB-ncpio\fR \fIdevice\fR\fR 484 .ad 485 .RS 17n 486 Always true. Writes the current file on \fIdevice\fR in \fBcpio\fR \fB-c\fR 487 format (5120 byte records). 488 .RE 489 490 .sp 491 .ne 2 492 .na 493 \fB\fB-newer\fR \fIfile\fR\fR 494 .ad 495 .RS 17n 496 True if the current file has been modified more recently than the argument 497 \fIfile\fR. 498 .RE 499 500 .sp 501 .ne 2 502 .na 503 \fB\fB-nogroup\fR\fR 504 .ad 505 .RS 17n 506 True if the file belongs to non-existing group. 507 .RE 508 509 .sp 510 .ne 2 511 .na 512 \fB\fB-nouser\fR\fR 513 .ad 514 .RS 17n 515 True if the file belongs to non-existing user. 516 .RE 517 518 .sp 519 .ne 2 520 .na 521 \fB\fB-ok\fR \fIcommand\fR\fR 522 .ad 523 .RS 17n 524 Like \fB-exec\fR, except that the generated command line is printed with a 525 question mark first, and is executed only if the response is affirmative. 526 .RE 527 528 .sp 529 .ne 2 530 .na 531 \fB\fB-perm\fR [\fB-\fR]\fImode\fR\fR 532 .ad 533 .RS 17n 534 The \fImode\fR argument is used to represent file mode bits. It is identical in 535 format to the symbolic mode operand, \fIsymbolic_mode_list\fR, described in 536 \fBchmod\fR(1), and is interpreted as follows. To start, a template is assumed 537 with all file mode bits cleared. An \fIop\fR symbol of: 538 .sp 539 .ne 2 540 .na 541 \fB\fB+\fR\fR 542 .ad 543 .RS 8n 544 Set the appropriate mode bits in the template 545 .RE 546 547 .sp 548 .ne 2 549 .na 550 \fB\fB\(mi\fR\fR 551 .ad 552 .RS 8n 553 Clear the appropriate bits 554 .RE 555 556 .sp 557 .ne 2 558 .na 559 \fB\fB=\fR\fR 560 .ad 561 .RS 8n 562 Set the appropriate mode bits, without regard to the contents of the file mode 563 creation mask of the process 564 .RE 565 566 The \fIop\fR symbol of \fB\(mi\fR cannot be the first character of \fImode\fR, 567 to avoid ambiguity with the optional leading hyphen. Since the initial mode is 568 all bits off, there are no symbolic modes that need to use \fB\(mi\fR as the 569 first character. 570 .sp 571 If the hyphen is omitted, the primary evaluates as true when the file 572 permission bits exactly match the value of the resulting template. 573 .sp 574 Otherwise, if \fImode\fR is prefixed by a hyphen, the primary evaluates as true 575 if at least all the bits in the resulting template are set in the file 576 permission bits. 577 .RE 578 579 .sp 580 .ne 2 581 .na 582 \fB\fB-perm\fR [\fB-\fR]\fIonum\fR\fR 583 .ad 584 .RS 17n 585 True if the file permission flags exactly match the octal number \fIonum\fR 586 (see \fBchmod\fR(1)). If \fIonum\fR is prefixed by a minus sign (\fB\(mi\fR), 587 only the bits that are set in \fIonum\fR are compared with the file permission 588 flags, and the expression evaluates true if they match. 589 .RE 590 591 .sp 592 .ne 2 593 .na 594 \fB\fB-print\fR\fR 595 .ad 596 .RS 17n 597 Always true. Causes the current pathname to be printed. 598 .RE 599 600 .sp 601 .ne 2 602 .na 603 \fB\fB-print0\fR\fR 604 .ad 605 .RS 17n 606 Always true. Causes the current pathname to be printed, terminated by an ASCII 607 NUL character (character code 0) instead of a newline. 608 .RE 609 610 .sp 611 .ne 2 612 .na 613 \fB\fB-prune\fR\fR 614 .ad 615 .RS 17n 616 Always yields true. Does not examine any directories or files in the directory 617 structure below the \fIpattern\fR just matched. (See EXAMPLES). If \fB-depth\fR 618 is specified, \fB-prune\fR has no effect. 619 .RE 620 621 .sp 622 .ne 2 623 .na 624 \fB\fB-regex\fR \fIpattern\fR\fB 625 .ad 626 .RS 17n 627 True if the full path of the file matches \fIpattern\fR using regular 628 expressions. 629 .RE 630 631 .sp 632 .ne 2 633 .na 634 \fB\fB-size\fR \fIn\fR[\fBc\fR]\fR 635 .ad 636 .RS 17n 637 True if the file is \fIn\fR blocks long (512 bytes per block). If \fIn\fR is 638 followed by a \fBc\fR, the size is in bytes. 639 .RE 640 641 .sp 642 .ne 2 643 .na 644 \fB\fB-type\fR \fIc\fR\fR 645 .ad 646 .RS 17n 647 True if the type of the file is \fIc\fR, where \fIc\fR is \fBb\fR, \fBc\fR, 648 \fBd\fR, \fBD\fR, \fBf\fR, \fBl\fR, \fBp\fR, or \fBs\fR for block special file, 649 character special file, directory, door, plain file, symbolic link, fifo (named 650 pipe), or socket, respectively. 651 .RE 652 653 .sp 654 .ne 2 655 .na 656 \fB\fB-user\fR \fIuname\fR\fR 657 .ad 658 .RS 17n 659 True if the file belongs to the user \fIuname\fR. If \fIuname\fR is numeric and 660 there's no such user name, it is taken as a user \fBID\fR. 661 .RE 662 663 .sp 664 .ne 2 665 .na 666 \fB\fB-useracl\fR \fIuname\fR\fR 667 .ad 668 .RS 17n 669 True if the file's ACL contains an entry for the user \fIuname\fR. 670 If \fIuname\fR is numeric and there's no such user name, it is 671 taken as a user \fBID\fR. 672 .RE 673 674 .sp 675 .ne 2 676 .na 677 \fB\fB-xdev\fR\fR 678 .ad 679 .RS 17n 680 Same as the \fB-mount\fR primary. 681 .RE 682 683 .sp 684 .ne 2 685 .na 686 \fB\fB-xattr\fR\fR 687 .ad 688 .RS 17n 689 True if the file has extended attributes. 690 .RE 691 692 .SS "Complex Expressions" 693 .sp 694 .LP 695 The primaries can be combined using the following operators (in order of 696 decreasing precedence): 697 .sp 698 .ne 2 699 .na 700 \fB1)\fB(\fR\fIexpression\fR\fB)\fR\fR 701 .ad 702 .sp .6 703 .RS 4n 704 True if the parenthesized expression is true (parentheses are special to the 705 shell and must be escaped). 706 .RE 707 708 .sp 709 .ne 2 710 .na 711 \fB2)\fB!\fR\fIexpression\fR\fR 712 .ad 713 .sp .6 714 .RS 4n 715 The negation of a primary (\fB!\fR is the unary \fInot\fR operator). 716 .RE 717 718 .sp 719 .ne 2 720 .na 721 \fB3) \fIexpression\fR\fB[\fR\fB-a\fR\fB]\fR \fIexpression\fR\fR 722 .ad 723 .sp .6 724 .RS 4n 725 Concatenation of primaries (the \fIand\fR operation is implied by the 726 juxtaposition of two primaries). 727 .RE 728 729 .sp 730 .ne 2 731 .na 732 \fB4) \fIexpression\fR\fB\fR\fB-o\fR\fIexpression\fR\fR 733 .ad 734 .sp .6 735 .RS 4n 736 Alternation of primaries (\fB-o\fR is the \fIor\fR operator). 737 .RE 738 739 .sp 740 .LP 741 When you use \fBfind\fR in conjunction with \fBcpio\fR, if you use the \fB-L\fR 742 option with \fBcpio\fR, you must use the \fB-L\fR option or the \fB-follow\fR 743 primitive with \fBfind\fR and vice versa. Otherwise the results are 744 unspecified. 745 .sp 746 .LP 747 If no \fIexpression\fR is present, \fB-print\fR is used as the expression. 748 Otherwise, if the specified expression does not contain any of the primaries 749 \fB-exec\fR, \fB-ok\fR, \fB-ls\fR, or \fB-print\fR, the specified expression is 750 effectively replaced by: 751 .sp 752 .LP 753 (\fIspecified\fR) \fB-print\fR 754 .sp 755 .LP 756 The \fB-user\fR, \fB-group\fR, and \fB-newer\fR primaries each evaluate their 757 respective arguments only once. Invocation of \fIcommand\fR specified by 758 \fB-exec\fR or \fB-ok\fR does not affect subsequent primaries on the same file. 759 .SH USAGE 760 .sp 761 .LP 762 See \fBlargefile\fR(5) for the description of the behavior of \fBfind\fR when 763 encountering files greater than or equal to 2 Gbyte (2^31 bytes). 764 .SH EXAMPLES 765 .LP 766 \fBExample 1 \fRWriting Out the Hierarchy Directory 767 .sp 768 .LP 769 The following commands are equivalent: 770 771 .sp 772 .in +2 773 .nf 774 example% \fBfind .\fR 775 example% \fBfind . -print\fR 776 .fi 777 .in -2 778 .sp 779 780 .sp 781 .LP 782 They both write out the entire directory hierarchy from the current directory. 783 784 .LP 785 \fBExample 2 \fRRemoving Files 786 .sp 787 .LP 788 The following comand removes all files in your home directory named \fBa.out\fR 789 or \fB*.o\fR that have not been accessed for a week: 790 791 .sp 792 .in +2 793 .nf 794 example% \fBfind $HOME \e( -name a.out -o -name '*.o' \e) \e 795 -atime +7 -exec rm {} \e;\fR 796 .fi 797 .in -2 798 .sp 799 800 .LP 801 \fBExample 3 \fRPrinting All File Names But Skipping SCCS Directories 802 .sp 803 .LP 804 The following command recursively print all file names in the current directory 805 and below, but skipping \fBSCCS\fR directories: 806 807 .sp 808 .in +2 809 .nf 810 example% \fBfind . -name SCCS -prune -o -print\fR 811 .fi 812 .in -2 813 .sp 814 815 .LP 816 \fBExample 4 \fRPrinting all file names and the SCCS directory name 817 .sp 818 .LP 819 Recursively print all file names in the current directory and below, skipping 820 the contents of \fBSCCS\fR directories, but printing out the \fBSCCS\fR 821 directory name: 822 823 .sp 824 .in +2 825 .nf 826 example% \fBfind . -print -name SCCS -prune\fR 827 .fi 828 .in -2 829 .sp 830 831 .LP 832 \fBExample 5 \fRTesting for the Newer File 833 .sp 834 .LP 835 The following command is basically equivalent to the \fB-nt\fR extension to 836 \fBtest\fR(1): 837 838 .sp 839 .in +2 840 .nf 841 example$ \fBif [ -n "$(find 842 file1 -prune -newer file2)" ]; then 843 844 printf %s\e\en "file1 is newer than file2"\fR 845 .fi 846 .in -2 847 .sp 848 849 .LP 850 \fBExample 6 \fRSelecting a File Using 24-hour Mode 851 .sp 852 .LP 853 The descriptions of \fB-atime\fR, \fB-ctime\fR, and \fB-mtime\fR use the 854 terminology \fIn\fR ``24-hour periods''. For example, a file accessed at 23:59 855 is selected by: 856 857 .sp 858 .in +2 859 .nf 860 example% \fBfind . -atime -1 -print\fR 861 .fi 862 .in -2 863 .sp 864 865 .sp 866 .LP 867 at 00:01 the next day (less than 24 hours later, not more than one day ago). 868 The midnight boundary between days has no effect on the 24-hour calculation. 869 870 .LP 871 \fBExample 7 \fRPrinting Files Matching a User's Permission Mode 872 .sp 873 .LP 874 The following command recursively print all file names whose permission mode 875 exactly matches read, write, and execute access for user, and read and execute 876 access for group and other: 877 878 .sp 879 .in +2 880 .nf 881 example% \fBfind . -perm u=rwx,g=rx,o=rx\fR 882 .fi 883 .in -2 884 .sp 885 886 .sp 887 .LP 888 The above could alternatively be specified as follows: 889 890 .sp 891 .in +2 892 .nf 893 example% \fBfind . -perm a=rwx,g-w,o-w\fR 894 .fi 895 .in -2 896 .sp 897 898 .LP 899 \fBExample 8 \fRPrinting Files with Write Access for \fBother\fR 900 .sp 901 .LP 902 The following command recursively print all file names whose permission 903 includes, but is not limited to, write access for other: 904 905 .sp 906 .in +2 907 .nf 908 example% \fBfind . -perm -o+w\fR 909 .fi 910 .in -2 911 .sp 912 913 .LP 914 \fBExample 9 \fRPrinting Local Files without Descending Non-local Directories 915 .sp 916 .in +2 917 .nf 918 example% \fBfind . ! -local -prune -o -print\fR 919 .fi 920 .in -2 921 .sp 922 923 .LP 924 \fBExample 10 \fRPrinting the Files in the Name Space Possessing Extended 925 Attributes 926 .sp 927 .in +2 928 .nf 929 example% \fBfind . -xattr\fR 930 .fi 931 .in -2 932 .sp 933 934 .SH ENVIRONMENT VARIABLES 935 .sp 936 .LP 937 See \fBenviron\fR(5) for descriptions of the following environment variables 938 that affect the execution of \fBfind\fR: \fBLANG\fR, \fBLC_ALL\fR, 939 \fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR. 940 .sp 941 .ne 2 942 .na 943 \fB\fBPATH\fR\fR 944 .ad 945 .RS 8n 946 Determine the location of the \fIutility_name\fR for the \fB-exec\fR and 947 \fB-ok\fR primaries. 948 .RE 949 950 .sp 951 .LP 952 Affirmative responses are processed using the extended regular expression 953 defined for the \fByesexpr\fR keyword in the \fBLC_MESSAGES\fR category of the 954 user's locale. The locale specified in the \fBLC_COLLATE\fR category defines 955 the behavior of ranges, equivalence classes, and multi-character collating 956 elements used in the expression defined for \fByesexpr\fR. The locale specified 957 in \fBLC_CTYPE\fR determines the locale for interpretation of sequences of 958 bytes of text data a characters, the behavior of character classes used in the 959 expression defined for the \fByesexpr\fR. See \fBlocale\fR(5). 960 .SH EXIT STATUS 961 .sp 962 .LP 963 The following exit values are returned: 964 .sp 965 .ne 2 966 .na 967 \fB\fB0\fR\fR 968 .ad 969 .RS 6n 970 All \fIpath\fR operands were traversed successfully. 971 .RE 972 973 .sp 974 .ne 2 975 .na 976 \fB\fB>0\fR\fR 977 .ad 978 .RS 6n 979 An error occurred. 980 .RE 981 982 .SH FILES 983 .sp 984 .ne 2 985 .na 986 \fB\fB/etc/passwd\fR\fR 987 .ad 988 .RS 20n 989 Password file 990 .RE 991 992 .sp 993 .ne 2 994 .na 995 \fB\fB/etc/group\fR\fR 996 .ad 997 .RS 20n 998 Group file 999 .RE 1000 1001 .sp 1002 .ne 2 1003 .na 1004 \fB\fB/etc/dfs/fstypes\fR\fR 1005 .ad 1006 .RS 20n 1007 File that registers distributed file system packages 1008 .RE 1009 1010 .SH ATTRIBUTES 1011 .sp 1012 .LP 1013 See \fBattributes\fR(5) for descriptions of the following attributes: 1014 .sp 1015 1016 .sp 1017 .TS 1018 box; 1019 c | c 1020 l | l . 1021 ATTRIBUTE TYPE ATTRIBUTE VALUE 1022 _ 1023 CSI Enabled 1024 _ 1025 Interface Stability Committed 1026 _ 1027 Standard See \fBstandards\fR(5). 1028 .TE 1029 1030 .SH SEE ALSO 1031 .sp 1032 .LP 1033 \fBchmod\fR(1), \fBcpio\fR(1), \fBsh\fR(1), \fBtest\fR(1), \fBls\fR(1B), 1034 \fBacl\fR(5), \fBregex\fR(5), \fBstat\fR(2), \fBumask\fR(2), 1035 \fBattributes\fR(5), \fBenviron\fR(5), \fBfsattr\fR(5), \fBlargefile\fR(5), 1036 \fBlocale\fR(5), \fBstandards\fR(5) 1037 .SH WARNINGS 1038 .sp 1039 .LP 1040 The following options are obsolete and will not be supported in future 1041 releases: 1042 .sp 1043 .ne 2 1044 .na 1045 \fB\fB-cpio\fR \fIdevice\fR\fR 1046 .ad 1047 .RS 17n 1048 Always true. Writes the current file on \fIdevice\fR in \fBcpio\fR format 1049 (5120-byte records). 1050 .RE 1051 1052 .sp 1053 .ne 2 1054 .na 1055 \fB\fB-ncpio\fR \fIdevice\fR\fR 1056 .ad 1057 .RS 17n 1058 Always true. Writes the current file on \fIdevice\fR in \fBcpio\fR \fB-c\fR 1059 format (5120-byte records). 1060 .RE 1061 1062 .SH NOTES 1063 .sp 1064 .LP 1065 When using \fBfind\fR to determine files modified within a range of time, use 1066 the \fB-mtime\fR argument \fBbefore\fR the \fB-print\fR argument. Otherwise, 1067 \fBfind\fR gives all files. 1068 .sp 1069 .LP 1070 Some files that might be under the Solaris root file system are actually mount 1071 points for virtual file systems, such as \fBmntfs\fR or \fBnamefs\fR. When 1072 comparing against a \fBufs\fR file system, such files are not selected if 1073 \fB-mount\fR or \fB-xdev\fR is specified in the \fBfind\fR expression. 1074 .sp 1075 .LP 1076 Using the \fB-L\fR or \fB-follow\fR option is not recommended when descending a 1077 file-system hierarchy that is under the control of other users. In particular, 1078 when using \fB-exec\fR, symbolic links can lead the \fBfind\fR command out of 1079 the hierarchy in which it started. Using \fB-type\fR is not sufficient to 1080 restrict the type of files on which the \fB-exec\fR command operates, because 1081 there is an inherent race condition between the type-check performed by the 1082 \fBfind\fR command and the time the executed command operates on the file 1083 argument.