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 .\" Copyright 2020 Joyent, Inc.
  49 .\"
  50 .TH FIND 1 "Feb 20, 2020"
  51 .SH NAME
  52 find \- find files
  53 .SH SYNOPSIS
  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 The \fBfind\fR utility recursively descends the directory hierarchy for each
  65 \fIpath\fR seeking files that match a Boolean \fIexpression\fR written in the
  66 primaries specified below.
  67 .sp
  68 .LP
  69 \fBfind\fR is able to descend to arbitrary depths in a file hierarchy and does
  70 not fail due to path length limitations (unless a \fIpath\fR operand specified
  71 by the application exceeds \fIPATH_MAX\fR requirements).
  72 .sp
  73 .LP
  74 \fBfind\fR detects infinite loops; that is, entering a previously visited
  75 directory that is an ancestor of the last file encountered.
  76 .SH OPTIONS
  77 The following options are supported:
  78 .sp
  79 .ne 2
  80 .na
  81 \fB\fB-E\fR\fR
  82 .ad
  83 .RS 6n
  84 Interpret regular expressions followed by \fB-regex\fR and \fB-iregex\fR
  85 primaries as extended regular expressions.
  86 .RE
  87 
  88 .sp
  89 .ne 2
  90 .na
  91 \fB\fB-H\fR\fR
  92 .ad
  93 .RS 6n
  94 Causes the file information and file type evaluated for each symbolic link
  95 encountered on the command line to be those of the file referenced by the link,
  96 and not the link itself. If the referenced file does not exist, the file
  97 information and type is for the link itself. File information for all symbolic
  98 links not on the command line is that of the link itself.
  99 .RE
 100 
 101 .sp
 102 .ne 2
 103 .na
 104 \fB\fB-L\fR\fR
 105 .ad
 106 .RS 6n
 107 Causes the file information and file type evaluated for each symbolic link to
 108 be those of the file referenced by the link, and not the link itself. See
 109 \fBNOTES\fR.
 110 .RE
 111 
 112 .sp
 113 .LP
 114 Specifying more than one of the mutually-exclusive options \fB-H\fR and
 115 \fB-L\fR is not considered an error. The last option specified determines the
 116 behavior of the utility.
 117 .SH OPERANDS
 118 The following operands are supported:
 119 .sp
 120 .ne 2
 121 .na
 122 \fB\fIpath\fR\fR
 123 .ad
 124 .RS 14n
 125 A pathname of a starting point in the directory hierarchy.
 126 .RE
 127 
 128 .sp
 129 .ne 2
 130 .na
 131 \fB\fIexpression\fR\fR
 132 .ad
 133 .RS 14n
 134 The first argument that starts with a \fB\(mi\fR, or is a \fB!\fR or a \fB(\fR,
 135 and all subsequent arguments are interpreted as an \fIexpression\fR made up of
 136 the following primaries and operators. In the descriptions, wherever \fIn\fR is
 137 used as a primary argument, it is interpreted as a decimal integer optionally
 138 preceded by a plus (\fB+\fR) or minus (\fB\(mi\fR) sign, as follows:
 139 .sp
 140 .ne 2
 141 .na
 142 \fB+\fIn\fR\fR
 143 .ad
 144 .RS 6n
 145 more than \fIn\fR
 146 .RE
 147 
 148 .sp
 149 .ne 2
 150 .na
 151 \fB\fIn\fR\fR
 152 .ad
 153 .RS 6n
 154 exactly \fIn\fR
 155 .RE
 156 
 157 .sp
 158 .ne 2
 159 .na
 160 \fB-\fIn\fR\fR
 161 .ad
 162 .RS 6n
 163 less than \fIn\fR
 164 .RE
 165 
 166 .RE
 167 
 168 .SS "Expressions"
 169 Valid expressions are:
 170 .sp
 171 .ne 2
 172 .na
 173 \fB\fB-acl\fR\fR
 174 .ad
 175 .RS 17n
 176 True if the file have additional ACLs defined.
 177 .RE
 178 
 179 .sp
 180 .ne 2
 181 .na
 182 \fB\fB-amin\fR \fIn\fR\fR
 183 .ad
 184 .RS 17n
 185 File was last accessed \fIn\fR minutes ago.
 186 .RE
 187 
 188 .sp
 189 .ne 2
 190 .na
 191 \fB\fB-atime\fR \fIn\fR\fR
 192 .ad
 193 .RS 17n
 194 True if the file was accessed \fIn\fR days ago. The access time of directories
 195 in \fIpath\fR is changed by \fBfind\fR itself.
 196 .RE
 197 
 198 .sp
 199 .ne 2
 200 .na
 201 \fB\fB-cmin\fR \fIn\fR\fR
 202 .ad
 203 .RS 17n
 204 File's status was last changed \fIn\fR minutes ago.
 205 .RE
 206 
 207 .sp
 208 .ne 2
 209 .na
 210 \fB\fB-cpio\fR \fIdevice\fR\fR
 211 .ad
 212 .RS 17n
 213 Always true. Writes the current file on \fIdevice\fR in \fBcpio\fR format
 214 (5120-byte records).
 215 .RE
 216 
 217 .sp
 218 .ne 2
 219 .na
 220 \fB\fB-ctime\fR \fIn\fR\fR
 221 .ad
 222 .RS 17n
 223 True if the file's status was changed \fIn\fR days ago.
 224 .RE
 225 
 226 .sp
 227 .ne 2
 228 .na
 229 \fB\fB-depth\fR\fR
 230 .ad
 231 .RS 17n
 232 Always true. Causes descent of the directory hierarchy to be done so that all
 233 entries in a directory are acted on before the directory itself. This can be
 234 useful when \fBfind\fR is used with \fBcpio\fR(1) to transfer files that are
 235 contained in directories without write permission.
 236 .RE
 237 
 238 .sp
 239 .ne 2
 240 .na
 241 \fB\fB-exec\fR \fIcommand\fR\fR
 242 .ad
 243 .RS 17n
 244 True if the executed command returns a zero value as exit status. The end of
 245 command must be punctuated by an escaped semicolon (\fB;\fR). A command
 246 argument \fB{}\fR is replaced by the current pathname. If the last argument to
 247 \fB-exec\fR is \fB{}\fR and you specify \fB+\fR rather than the semicolon
 248 (\fB;\fR), the command is invoked fewer times, with \fB{}\fR replaced by groups
 249 of pathnames. If any invocation of the command returns a non-zero value as exit
 250 status, find returns a non-zero exit status.
 251 .RE
 252 
 253 .sp
 254 .ne 2
 255 .na
 256 \fB\fB-follow\fR\fR
 257 .ad
 258 .RS 17n
 259 Always true and always evaluated no matter where it appears in
 260 \fIexpression\fR. The behavior is unspecified if \fB-follow\fR is used when the
 261 \fBfind\fR command is invoked with either the \fB-H\fR or the \fB-L\fR option.
 262 Causes symbolic links to be followed. When following symbolic links, \fBfind\fR
 263 keeps track of the directories visited so that it can detect infinite loops.
 264 For example, such a loop would occur if a symbolic link pointed to an ancestor.
 265 This expression should not be used with the find-type \fBl\fR expression. See
 266 \fBNOTES\fR.
 267 .RE
 268 
 269 .sp
 270 .ne 2
 271 .na
 272 \fB\fB-fstype\fR \fItype\fR\fR
 273 .ad
 274 .RS 17n
 275 True if the filesystem to which the file belongs is of type \fItype\fR.
 276 .RE
 277 
 278 .sp
 279 .ne 2
 280 .na
 281 \fB\fB-group\fR \fIgname\fR\fR
 282 .ad
 283 .RS 17n
 284 True if the file belongs to the group \fIgname\fR. If \fIgname\fR is numeric
 285 and there's no such group name, it is taken as a group \fBID\fR.
 286 .RE
 287 
 288 .sp
 289 .ne 2
 290 .na
 291 \fB\fB-groupacl\fR \fIgname\fR\fR
 292 .ad
 293 .RS 17n
 294 True if the file's ACL contains an entry for the group \fIgname\fR.
 295 If \fIgname\fR is numeric and there's no such group name, it is taken
 296 as a group \fBID\fR.
 297 .RE
 298 
 299 .sp
 300 .ne 2
 301 .na
 302 \fB\fB-iname\fR \fIpattern\fR\fR
 303 .ad
 304 .RS 17n
 305 Like \fB-name\fR, but the match is case insensitive.
 306 .RE
 307 
 308 .sp
 309 .ne 2
 310 .na
 311 \fB\fB-inum\fR \fIn\fR\fR
 312 .ad
 313 .RS 17n
 314 True if the file has inode number \fIn\fR.
 315 .RE
 316 
 317 .sp
 318 .ne 2
 319 .na
 320 \fB\fB-ipath\fR \fIpattern\fR\fR
 321 .ad
 322 .RS 17n
 323 Like \fB-path\fR, but the match is case insensitive.
 324 .RE
 325 
 326 .sp
 327 .ne 2
 328 .na
 329 \fB\fB-iregex\fR \fIpattern\fR\fR
 330 .ad
 331 .RS 17n
 332 Like \fB-regex\fR, but the match is case insensitive.
 333 .RE
 334 
 335 .sp
 336 .ne 2
 337 .na
 338 \fB\fB-links\fR \fIn\fR\fR
 339 .ad
 340 .RS 17n
 341 True if the file has \fIn\fR links.
 342 .RE
 343 
 344 .sp
 345 .ne 2
 346 .na
 347 \fB\fB-local\fR\fR
 348 .ad
 349 .RS 17n
 350 True if the file system type is not a remote file system type as defined in the
 351 \fB/etc/dfs/fstypes\fR file. \fBnfs\fR is used as the default remote filesystem
 352 type if the \fB/etc/dfs/fstypes\fR file is not present. The \fB-local\fR option
 353 descends the hierarchy of non-local directories. See \fBEXAMPLES\fR for an
 354 example of how to search for local files without descending.
 355 .RE
 356 
 357 .sp
 358 .ne 2
 359 .na
 360 \fB\fB-ls\fR\fR
 361 .ad
 362 .RS 17n
 363 Always true. Prints current pathname together with its associated statistics.
 364 These include (respectively):
 365 .RS +4
 366 .TP
 367 .ie t \(bu
 368 .el o
 369 inode number
 370 .RE
 371 .RS +4
 372 .TP
 373 .ie t \(bu
 374 .el o
 375 size in kilobytes (1024 bytes)
 376 .RE
 377 .RS +4
 378 .TP
 379 .ie t \(bu
 380 .el o
 381 protection mode
 382 .RE
 383 .RS +4
 384 .TP
 385 .ie t \(bu
 386 .el o
 387 number of hard links
 388 .RE
 389 .RS +4
 390 .TP
 391 .ie t \(bu
 392 .el o
 393 user
 394 .RE
 395 .RS +4
 396 .TP
 397 .ie t \(bu
 398 .el o
 399 group
 400 .RE
 401 .RS +4
 402 .TP
 403 .ie t \(bu
 404 .el o
 405 size in bytes
 406 .RE
 407 .RS +4
 408 .TP
 409 .ie t \(bu
 410 .el o
 411 modification time.
 412 .RE
 413 If the file is a special file, the size field instead contains the major and
 414 minor device numbers.
 415 .sp
 416 If the file is a symbolic link, the pathname of the linked-to file is printed
 417 preceded by `\fB\(->\fR\&'. The format is identical to that of \fBls\fR
 418 \fB-gilds\fR (see \fBls\fR(1B)).
 419 .sp
 420 Formatting is done internally, without executing the \fBls\fR program.
 421 .RE
 422 
 423 .sp
 424 .ne 2
 425 .na
 426 \fB\fB-maxdepth\fR \fIn\fR\fR
 427 .ad
 428 .RS 17n
 429 Always true; descend at most \fIn\fR directory levels below the command
 430 line arguments. If any \fB-maxdepth\fR primary is specified, it
 431 applies to the entire expression even if it would not normally be
 432 evaluated. \fB-maxdepth 0\fR limits the whole search to
 433 the command line arguments.
 434 .RE
 435 
 436 .sp
 437 .ne 2
 438 .na
 439 \fB\fB-mindepth\fR \fIn\fR\fR
 440 .ad
 441 .RS 17n
 442 Always true; do not apply any tests or actions at levels less
 443 than \fIn\fR. If any \fB-mindepth\fR primary is specified, it applies to the
 444 entire expression even if it would not normally be evaluated.
 445 \fB-mindepth 1\fR processes all but the command line arguments.
 446 .RE
 447 
 448 .sp
 449 .ne 2
 450 .na
 451 \fB\fB-mmin\fR \fIn\fR\fR
 452 .ad
 453 .RS 17n
 454 File's data was last modified \fIn\fR minutes ago.
 455 .RE
 456 
 457 .sp
 458 .ne 2
 459 .na
 460 \fB\fB-mount\fR\fR
 461 .ad
 462 .RS 17n
 463 Always true. Restricts the search to the file system containing the directory
 464 specified. Does not list mount points to other file systems.
 465 .RE
 466 
 467 .sp
 468 .ne 2
 469 .na
 470 \fB\fB-mtime\fR \fIn\fR\fR
 471 .ad
 472 .RS 17n
 473 True if the file's data was modified \fIn\fR days ago.
 474 .RE
 475 
 476 .sp
 477 .ne 2
 478 .na
 479 \fB\fB-name\fR \fIpattern\fR\fR
 480 .ad
 481 .RS 17n
 482 True if \fIpattern\fR matches the basename of the current file name. Normal
 483 shell file name generation characters (see \fBsh\fR(1)) can be used. A
 484 backslash (\fB\|\e\|\fR) is used as an escape character within the pattern. The
 485 pattern should be escaped or quoted when \fBfind\fR is invoked from the shell.
 486 .sp
 487 Unless the character '\fB\&.\fR' is explicitly specified in the beginning of
 488 \fIpattern\fR, a current file name beginning with '\fB\&.\fR' does not match
 489 \fIpattern\fR when using \fB/usr/bin/find\fR. \fB/usr/xpg4/bin/find\fR does not
 490 make this distinction; wildcard file name generation characters can match file
 491 names beginning with '\fB\&.\fR'.
 492 .RE
 493 
 494 .sp
 495 .ne 2
 496 .na
 497 \fB\fB-ncpio\fR \fIdevice\fR\fR
 498 .ad
 499 .RS 17n
 500 Always true. Writes the current file on \fIdevice\fR in \fBcpio\fR \fB-c\fR
 501 format (5120 byte records).
 502 .RE
 503 
 504 .sp
 505 .ne 2
 506 .na
 507 \fB\fB-newer\fR \fIfile\fR\fR
 508 .ad
 509 .RS 17n
 510 True if the current file has been modified more recently than the argument
 511 \fIfile\fR.
 512 .RE
 513 
 514 .sp
 515 .ne 2
 516 .na
 517 \fB\fB-nogroup\fR\fR
 518 .ad
 519 .RS 17n
 520 True if the file belongs to non-existing group.
 521 .RE
 522 
 523 .sp
 524 .ne 2
 525 .na
 526 \fB\fB-nouser\fR\fR
 527 .ad
 528 .RS 17n
 529 True if the file belongs to non-existing user.
 530 .RE
 531 
 532 .sp
 533 .ne 2
 534 .na
 535 \fB\fB-ok\fR \fIcommand\fR\fR
 536 .ad
 537 .RS 17n
 538 Like \fB-exec\fR, except that the generated command line is printed with a
 539 question mark first, and is executed only if the response is affirmative.
 540 .RE
 541 
 542 .sp
 543 .ne 2
 544 .na
 545 \fB\fB-path\fR\fR
 546 .ad
 547 .RS 17n
 548 Like \fB-name\fR, but matches the entire file path and not just basename, and
 549 without any special treatment of leading periods.
 550 .RE
 551 
 552 .sp
 553 .ne 2
 554 .na
 555 \fB\fB-perm\fR [\fB-\fR]\fImode\fR\fR
 556 .ad
 557 .RS 17n
 558 The \fImode\fR argument is used to represent file mode bits. It is identical in
 559 format to the symbolic mode operand, \fIsymbolic_mode_list\fR, described in
 560 \fBchmod\fR(1), and is interpreted as follows. To start, a template is assumed
 561 with all file mode bits cleared. An \fIop\fR symbol of:
 562 .sp
 563 .ne 2
 564 .na
 565 \fB\fB+\fR\fR
 566 .ad
 567 .RS 8n
 568 Set the appropriate mode bits in the template
 569 .RE
 570 
 571 .sp
 572 .ne 2
 573 .na
 574 \fB\fB\(mi\fR\fR
 575 .ad
 576 .RS 8n
 577 Clear the appropriate bits
 578 .RE
 579 
 580 .sp
 581 .ne 2
 582 .na
 583 \fB\fB=\fR\fR
 584 .ad
 585 .RS 8n
 586 Set the appropriate mode bits, without regard to the contents of the file mode
 587 creation mask of the process
 588 .RE
 589 
 590 The \fIop\fR symbol of \fB\(mi\fR cannot be the first character of \fImode\fR,
 591 to avoid ambiguity with the optional leading hyphen. Since the initial mode is
 592 all bits off, there are no symbolic modes that need to use \fB\(mi\fR as the
 593 first character.
 594 .sp
 595 If the hyphen is omitted, the primary evaluates as true when the file
 596 permission bits exactly match the value of the resulting template.
 597 .sp
 598 Otherwise, if \fImode\fR is prefixed by a hyphen, the primary evaluates as true
 599 if at least all the bits in the resulting template are set in the file
 600 permission bits.
 601 .RE
 602 
 603 .sp
 604 .ne 2
 605 .na
 606 \fB\fB-perm\fR [\fB-\fR]\fIonum\fR\fR
 607 .ad
 608 .RS 17n
 609 True if the file permission flags exactly match the octal number \fIonum\fR
 610 (see \fBchmod\fR(1)). If \fIonum\fR is prefixed by a minus sign (\fB\(mi\fR),
 611 only the bits that are set in \fIonum\fR are compared with the file permission
 612 flags, and the expression evaluates true if they match.
 613 .RE
 614 
 615 .sp
 616 .ne 2
 617 .na
 618 \fB\fB-print\fR\fR
 619 .ad
 620 .RS 17n
 621 Always true. Causes the current pathname to be printed.
 622 .RE
 623 
 624 .sp
 625 .ne 2
 626 .na
 627 \fB\fB-print0\fR\fR
 628 .ad
 629 .RS 17n
 630 Always true. Causes the current pathname to be printed, terminated by an ASCII
 631 NUL character (character code 0) instead of a newline.
 632 .RE
 633 
 634 .sp
 635 .ne 2
 636 .na
 637 \fB\fB-prune\fR\fR
 638 .ad
 639 .RS 17n
 640 Always yields true. Does not examine any directories or files in the directory
 641 structure below the \fIpattern\fR just matched. (See EXAMPLES). If \fB-depth\fR
 642 is specified, \fB-prune\fR has no effect.
 643 .RE
 644 
 645 .sp
 646 .ne 2
 647 .na
 648 \fB\fB-regex\fR \fIpattern\fR\fB
 649 .ad
 650 .RS 17n
 651 True if the full path of the file matches \fIpattern\fR using regular
 652 expressions.
 653 .RE
 654 
 655 .sp
 656 .ne 2
 657 .na
 658 \fB\fB-size\fR \fIn\fR[\fBc\fR]\fR
 659 .ad
 660 .RS 17n
 661 True if the file is \fIn\fR blocks long (512 bytes per block). If \fIn\fR is
 662 followed by a \fBc\fR, the size is in bytes.
 663 .RE
 664 
 665 .sp
 666 .ne 2
 667 .na
 668 \fB\fB-type\fR \fIc\fR\fR
 669 .ad
 670 .RS 17n
 671 True if the type of the file is \fIc\fR, where \fIc\fR is \fBb\fR, \fBc\fR,
 672 \fBd\fR, \fBD\fR, \fBf\fR, \fBl\fR, \fBp\fR, or \fBs\fR for block special file,
 673 character special file, directory, door, plain file, symbolic link, fifo (named
 674 pipe), or socket, respectively.
 675 .RE
 676 
 677 .sp
 678 .ne 2
 679 .na
 680 \fB\fB-user\fR \fIuname\fR\fR
 681 .ad
 682 .RS 17n
 683 True if the file belongs to the user \fIuname\fR. If \fIuname\fR is numeric and
 684 there's no such user name, it is taken as a user \fBID\fR.
 685 .RE
 686 
 687 .sp
 688 .ne 2
 689 .na
 690 \fB\fB-useracl\fR \fIuname\fR\fR
 691 .ad
 692 .RS 17n
 693 True if the file's ACL contains an entry for the user \fIuname\fR.
 694 If \fIuname\fR is numeric and there's no such user name, it is
 695 taken as a user \fBID\fR.
 696 .RE
 697 
 698 .sp
 699 .ne 2
 700 .na
 701 \fB\fB-xdev\fR\fR
 702 .ad
 703 .RS 17n
 704 Same as the \fB-mount\fR primary.
 705 .RE
 706 
 707 .sp
 708 .ne 2
 709 .na
 710 \fB\fB-xattr\fR\fR
 711 .ad
 712 .RS 17n
 713 True if the file has extended attributes.
 714 .RE
 715 
 716 .SS "Complex Expressions"
 717 The primaries can be combined using the following operators (in order of
 718 decreasing precedence):
 719 .sp
 720 .ne 2
 721 .na
 722 \fB1)\fB(\fR\fIexpression\fR\fB)\fR\fR
 723 .ad
 724 .sp .6
 725 .RS 4n
 726 True if the parenthesized expression is true (parentheses are special to the
 727 shell and must be escaped).
 728 .RE
 729 
 730 .sp
 731 .ne 2
 732 .na
 733 \fB2)\fB!\fR\fIexpression\fR\fR
 734 .ad
 735 .sp .6
 736 .RS 4n
 737 The negation of a primary (\fB!\fR is the unary \fInot\fR operator).
 738 .RE
 739 
 740 .sp
 741 .ne 2
 742 .na
 743 \fB3) \fIexpression\fR\fB[\fR\fB-a\fR\fB]\fR \fIexpression\fR\fR
 744 .ad
 745 .sp .6
 746 .RS 4n
 747 Concatenation of primaries (the \fIand\fR operation is implied by the
 748 juxtaposition of two primaries).
 749 .RE
 750 
 751 .sp
 752 .ne 2
 753 .na
 754 \fB4) \fIexpression\fR\fB\fR\fB-o\fR\fIexpression\fR\fR
 755 .ad
 756 .sp .6
 757 .RS 4n
 758 Alternation of primaries (\fB-o\fR is the \fIor\fR operator).
 759 .RE
 760 
 761 .sp
 762 .LP
 763 When you use \fBfind\fR in conjunction with \fBcpio\fR, if you use the \fB-L\fR
 764 option with \fBcpio\fR, you must use the \fB-L\fR option or the \fB-follow\fR
 765 primitive with \fBfind\fR and vice versa. Otherwise the results are
 766 unspecified.
 767 .sp
 768 .LP
 769 If no \fIexpression\fR is present, \fB-print\fR is used as the expression.
 770 Otherwise, if the specified expression does not contain any of the primaries
 771 \fB-exec\fR, \fB-ok\fR, \fB-ls\fR, or \fB-print\fR, the specified expression is
 772 effectively replaced by:
 773 .sp
 774 .LP
 775 (\fIspecified\fR) \fB-print\fR
 776 .sp
 777 .LP
 778 The \fB-user\fR, \fB-group\fR, and \fB-newer\fR primaries each evaluate their
 779 respective arguments only once. Invocation of \fIcommand\fR specified by
 780 \fB-exec\fR or \fB-ok\fR does not affect subsequent primaries on the same file.
 781 .SH USAGE
 782 See \fBlargefile\fR(5) for the description of the behavior of \fBfind\fR when
 783 encountering files greater than or equal to 2 Gbyte (2^31 bytes).
 784 .SH EXAMPLES
 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 command 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 See \fBenviron\fR(5) for descriptions of the following environment variables
 955 that affect the execution of \fBfind\fR: \fBLANG\fR, \fBLC_ALL\fR,
 956 \fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
 957 .sp
 958 .ne 2
 959 .na
 960 \fB\fBPATH\fR\fR
 961 .ad
 962 .RS 8n
 963 Determine the location of the \fIutility_name\fR for the \fB-exec\fR and
 964 \fB-ok\fR primaries.
 965 .RE
 966 
 967 .sp
 968 .LP
 969 Affirmative responses are processed using the extended regular expression
 970 defined for the \fByesexpr\fR keyword in the \fBLC_MESSAGES\fR category of the
 971 user's locale. The locale specified in the \fBLC_COLLATE\fR category defines
 972 the behavior of ranges, equivalence classes, and multi-character collating
 973 elements used in the expression defined for \fByesexpr\fR. The locale specified
 974 in \fBLC_CTYPE\fR determines the locale for interpretation of sequences of
 975 bytes of text data a characters, the behavior of character classes used in the
 976 expression defined for the \fByesexpr\fR. See \fBlocale\fR(5).
 977 .SH EXIT STATUS
 978 The following exit values are returned:
 979 .sp
 980 .ne 2
 981 .na
 982 \fB\fB0\fR\fR
 983 .ad
 984 .RS 6n
 985 All \fIpath\fR operands were traversed successfully.
 986 .RE
 987 
 988 .sp
 989 .ne 2
 990 .na
 991 \fB\fB>0\fR\fR
 992 .ad
 993 .RS 6n
 994 An error occurred.
 995 .RE
 996 
 997 .SH FILES
 998 .ne 2
 999 .na
1000 \fB\fB/etc/passwd\fR\fR
1001 .ad
1002 .RS 20n
1003 Password file
1004 .RE
1005 
1006 .sp
1007 .ne 2
1008 .na
1009 \fB\fB/etc/group\fR\fR
1010 .ad
1011 .RS 20n
1012 Group file
1013 .RE
1014 
1015 .sp
1016 .ne 2
1017 .na
1018 \fB\fB/etc/dfs/fstypes\fR\fR
1019 .ad
1020 .RS 20n
1021 File that registers distributed file system packages
1022 .RE
1023 
1024 .SH ATTRIBUTES
1025 See \fBattributes\fR(5) for descriptions of the following attributes:
1026 .sp
1027 
1028 .sp
1029 .TS
1030 box;
1031 c | c
1032 l | l .
1033 ATTRIBUTE TYPE  ATTRIBUTE VALUE
1034 _
1035 CSI     Enabled
1036 _
1037 Interface Stability     Committed
1038 _
1039 Standard        See \fBstandards\fR(5).
1040 .TE
1041 
1042 .SH SEE ALSO
1043 \fBchmod\fR(1), \fBcpio\fR(1), \fBsh\fR(1), \fBtest\fR(1), \fBls\fR(1B),
1044 \fBacl\fR(5), \fBregex\fR(5), \fBstat\fR(2), \fBumask\fR(2),
1045 \fBattributes\fR(5), \fBenviron\fR(5), \fBfsattr\fR(5), \fBlargefile\fR(5),
1046 \fBlocale\fR(5), \fBstandards\fR(5)
1047 .SH WARNINGS
1048 The following options are obsolete and will not be supported in future
1049 releases:
1050 .sp
1051 .ne 2
1052 .na
1053 \fB\fB-cpio\fR \fIdevice\fR\fR
1054 .ad
1055 .RS 17n
1056 Always true. Writes the current file on \fIdevice\fR in \fBcpio\fR format
1057 (5120-byte records).
1058 .RE
1059 
1060 .sp
1061 .ne 2
1062 .na
1063 \fB\fB-ncpio\fR \fIdevice\fR\fR
1064 .ad
1065 .RS 17n
1066 Always true. Writes the current file on \fIdevice\fR in \fBcpio\fR \fB-c\fR
1067 format (5120-byte records).
1068 .RE
1069 
1070 .SH NOTES
1071 When using \fBfind\fR to determine files modified within a range of time, use
1072 the \fB-mtime\fR argument \fBbefore\fR the \fB-print\fR argument. Otherwise,
1073 \fBfind\fR gives all files.
1074 .sp
1075 .LP
1076 Some files that might be under the Solaris root file system are actually mount
1077 points for virtual file systems, such as \fBmntfs\fR or \fBnamefs\fR. When
1078 comparing against a \fBufs\fR file system, such files are not selected if
1079 \fB-mount\fR or \fB-xdev\fR is specified in the \fBfind\fR expression.
1080 .sp
1081 .LP
1082 Using the \fB-L\fR or \fB-follow\fR option is not recommended when descending a
1083 file-system hierarchy that is under the control of other users. In particular,
1084 when using \fB-exec\fR, symbolic links can lead the \fBfind\fR command out of
1085 the hierarchy in which it started. Using \fB-type\fR is not sufficient to
1086 restrict the type of files on which the \fB-exec\fR command operates, because
1087 there is an inherent race condition between the type-check performed by the
1088 \fBfind\fR command and the time the executed command operates on the file
1089 argument.