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