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