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