Print this page
12328 FNMPERIOD makes little sense for find -path
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/man/man1/find.1.man.txt
+++ new/usr/src/man/man1/find.1.man.txt
1 1 FIND(1) User Commands FIND(1)
2 2
3 3
4 4
5 5 NAME
6 6 find - find files
7 7
8 8 SYNOPSIS
9 9 /usr/bin/find [-E] [-H | -L] path... expression
10 10
11 11
12 12 /usr/xpg4/bin/find [-H | -L] path... expression
13 13
14 14
15 15 DESCRIPTION
16 16 The find utility recursively descends the directory hierarchy for each
17 17 path seeking files that match a Boolean expression written in the
18 18 primaries specified below.
19 19
20 20
21 21 find is able to descend to arbitrary depths in a file hierarchy and
22 22 does not fail due to path length limitations (unless a path operand
23 23 specified by the application exceeds PATH_MAX requirements).
24 24
25 25
26 26 find detects infinite loops; that is, entering a previously visited
27 27 directory that is an ancestor of the last file encountered.
28 28
29 29 OPTIONS
30 30 The following options are supported:
31 31
32 32 -E
33 33 Interpret regular expressions followed by -regex and -iregex
34 34 primaries as extended regular expressions.
35 35
36 36
37 37 -H
38 38 Causes the file information and file type evaluated for each
39 39 symbolic link encountered on the command line to be those of the
40 40 file referenced by the link, and not the link itself. If the
41 41 referenced file does not exist, the file information and type is
42 42 for the link itself. File information for all symbolic links not
43 43 on the command line is that of the link itself.
44 44
45 45
46 46 -L
47 47 Causes the file information and file type evaluated for each
48 48 symbolic link to be those of the file referenced by the link, and
49 49 not the link itself. See NOTES.
50 50
51 51
52 52
53 53 Specifying more than one of the mutually-exclusive options -H and -L is
54 54 not considered an error. The last option specified determines the
55 55 behavior of the utility.
56 56
57 57 OPERANDS
58 58 The following operands are supported:
59 59
60 60 path
61 61 A pathname of a starting point in the directory
62 62 hierarchy.
63 63
64 64
65 65 expression
66 66 The first argument that starts with a -, or is a ! or a
67 67 (, and all subsequent arguments are interpreted as an
68 68 expression made up of the following primaries and
69 69 operators. In the descriptions, wherever n is used as a
70 70 primary argument, it is interpreted as a decimal integer
71 71 optionally preceded by a plus (+) or minus (-) sign, as
72 72 follows:
73 73
74 74 +n
75 75 more than n
76 76
77 77
78 78 n
79 79 exactly n
80 80
81 81
82 82 -n
83 83 less than n
84 84
85 85
86 86
87 87 Expressions
88 88 Valid expressions are:
89 89
90 90 -acl
91 91 True if the file have additional ACLs defined.
92 92
93 93
94 94 -amin n
95 95 File was last accessed n minutes ago.
96 96
97 97
98 98 -atime n
99 99 True if the file was accessed n days ago. The access
100 100 time of directories in path is changed by find itself.
101 101
102 102
103 103 -cmin n
104 104 File's status was last changed n minutes ago.
105 105
106 106
107 107 -cpio device
108 108 Always true. Writes the current file on device in cpio
109 109 format (5120-byte records).
110 110
111 111
112 112 -ctime n
113 113 True if the file's status was changed n days ago.
114 114
115 115
116 116 -depth
117 117 Always true. Causes descent of the directory hierarchy
118 118 to be done so that all entries in a directory are
119 119 acted on before the directory itself. This can be
120 120 useful when find is used with cpio(1) to transfer
121 121 files that are contained in directories without write
122 122 permission.
123 123
124 124
125 125 -exec command
126 126 True if the executed command returns a zero value as
127 127 exit status. The end of command must be punctuated by
128 128 an escaped semicolon (;). A command argument {} is
129 129 replaced by the current pathname. If the last argument
130 130 to -exec is {} and you specify + rather than the
131 131 semicolon (;), the command is invoked fewer times,
132 132 with {} replaced by groups of pathnames. If any
133 133 invocation of the command returns a non-zero value as
134 134 exit status, find returns a non-zero exit status.
135 135
136 136
137 137 -follow
138 138 Always true and always evaluated no matter where it
139 139 appears in expression. The behavior is unspecified if
140 140 -follow is used when the find command is invoked with
141 141 either the -H or the -L option. Causes symbolic links
142 142 to be followed. When following symbolic links, find
143 143 keeps track of the directories visited so that it can
144 144 detect infinite loops. For example, such a loop would
145 145 occur if a symbolic link pointed to an ancestor. This
146 146 expression should not be used with the find-type l
147 147 expression. See NOTES.
148 148
149 149
150 150 -fstype type
151 151 True if the filesystem to which the file belongs is of
152 152 type type.
153 153
154 154
155 155 -group gname
156 156 True if the file belongs to the group gname. If gname
157 157 is numeric and there's no such group name, it is taken
158 158 as a group ID.
159 159
160 160
161 161 -groupacl gname
162 162 True if the file's ACL contains an entry for the group
163 163 gname. If gname is numeric and there's no such group
164 164 name, it is taken as a group ID.
165 165
166 166
167 167 -iname pattern
168 168 Like -name, but the match is case insensitive.
169 169
170 170
171 171 -inum n
172 172 True if the file has inode number n.
173 173
174 174
175 175 -ipath pattern
176 176 Like -path, but the match is case insensitive.
177 177
178 178
179 179 -iregex pattern
180 180 Like -regex, but the match is case insensitive.
181 181
182 182
183 183 -links n
184 184 True if the file has n links.
185 185
186 186
187 187 -local
188 188 True if the file system type is not a remote file
189 189 system type as defined in the /etc/dfs/fstypes file.
190 190 nfs is used as the default remote filesystem type if
191 191 the /etc/dfs/fstypes file is not present. The -local
192 192 option descends the hierarchy of non-local
193 193 directories. See EXAMPLES for an example of how to
194 194 search for local files without descending.
195 195
196 196
197 197 -ls
198 198 Always true. Prints current pathname together with its
199 199 associated statistics. These include (respectively):
200 200
201 201 o inode number
202 202
203 203 o size in kilobytes (1024 bytes)
204 204
205 205 o protection mode
206 206
207 207 o number of hard links
208 208
209 209 o user
210 210
211 211 o group
212 212
213 213 o size in bytes
214 214
215 215 o modification time.
216 216 If the file is a special file, the size field instead
217 217 contains the major and minor device numbers.
218 218
219 219 If the file is a symbolic link, the pathname of the
220 220 linked-to file is printed preceded by `->'. The format
221 221 is identical to that of ls -gilds (see ls(1B)).
222 222
223 223 Formatting is done internally, without executing the
224 224 ls program.
225 225
226 226
227 227 -maxdepth n
228 228 Always true; descend at most n directory levels below
229 229 the command line arguments. If any -maxdepth primary
230 230 is specified, it applies to the entire expression even
231 231 if it would not normally be evaluated. -maxdepth 0
232 232 limits the whole search to the command line arguments.
233 233
234 234
235 235 -mindepth n
236 236 Always true; do not apply any tests or actions at
237 237 levels less than n. If any -mindepth primary is
238 238 specified, it applies to the entire expression even if
239 239 it would not normally be evaluated. -mindepth 1
240 240 processes all but the command line arguments.
241 241
242 242
243 243 -mmin n
244 244 File's data was last modified n minutes ago.
245 245
246 246
247 247 -mount
248 248 Always true. Restricts the search to the file system
249 249 containing the directory specified. Does not list
250 250 mount points to other file systems.
251 251
252 252
253 253 -mtime n
254 254 True if the file's data was modified n days ago.
255 255
256 256
257 257 -name pattern
258 258 True if pattern matches the basename of the current
259 259 file name. Normal shell file name generation
260 260 characters (see sh(1)) can be used. A backslash (\) is
261 261 used as an escape character within the pattern. The
262 262 pattern should be escaped or quoted when find is
263 263 invoked from the shell.
264 264
265 265 Unless the character '.' is explicitly specified in
266 266 the beginning of pattern, a current file name
267 267 beginning with '.' does not match pattern when using
268 268 /usr/bin/find. /usr/xpg4/bin/find does not make this
269 269 distinction; wildcard file name generation characters
270 270 can match file names beginning with '.'.
271 271
272 272
273 273 -ncpio device
274 274 Always true. Writes the current file on device in cpio
275 275 -c format (5120 byte records).
276 276
277 277
278 278 -newer file
279 279 True if the current file has been modified more
280 280 recently than the argument file.
281 281
282 282
283 283 -nogroup
284 284 True if the file belongs to non-existing group.
285 285
286 286
287 287 -nouser
288 288 True if the file belongs to non-existing user.
↓ open down ↓ |
288 lines elided |
↑ open up ↑ |
289 289
290 290
291 291 -ok command
292 292 Like -exec, except that the generated command line is
293 293 printed with a question mark first, and is executed
294 294 only if the response is affirmative.
295 295
296 296
297 297 -path
298 298 Like -name, but matches the entire file path and not
299 - just basename.
299 + just basename, and without any special treatment of
300 + leading periods.
300 301
301 302
302 303 -perm [-]mode
303 304 The mode argument is used to represent file mode bits.
304 305 It is identical in format to the symbolic mode
305 306 operand, symbolic_mode_list, described in chmod(1),
306 307 and is interpreted as follows. To start, a template is
307 308 assumed with all file mode bits cleared. An op symbol
308 309 of:
309 310
310 311 +
311 312 Set the appropriate mode bits in the template
312 313
313 314
314 315 -
315 316 Clear the appropriate bits
316 317
317 318
318 319 =
319 320 Set the appropriate mode bits, without regard
320 321 to the contents of the file mode creation mask
321 322 of the process
322 323
323 324 The op symbol of - cannot be the first character of
324 325 mode, to avoid ambiguity with the optional leading
325 326 hyphen. Since the initial mode is all bits off, there
326 327 are no symbolic modes that need to use - as the first
327 328 character.
328 329
329 330 If the hyphen is omitted, the primary evaluates as
330 331 true when the file permission bits exactly match the
331 332 value of the resulting template.
332 333
333 334 Otherwise, if mode is prefixed by a hyphen, the
334 335 primary evaluates as true if at least all the bits in
335 336 the resulting template are set in the file permission
336 337 bits.
337 338
338 339
339 340 -perm [-]onum
340 341 True if the file permission flags exactly match the
341 342 octal number onum (see chmod(1)). If onum is prefixed
342 343 by a minus sign (-), only the bits that are set in
343 344 onum are compared with the file permission flags, and
344 345 the expression evaluates true if they match.
345 346
346 347
347 348 -print
348 349 Always true. Causes the current pathname to be
349 350 printed.
350 351
351 352
352 353 -print0
353 354 Always true. Causes the current pathname to be
354 355 printed, terminated by an ASCII NUL character
355 356 (character code 0) instead of a newline.
356 357
357 358
358 359 -prune
359 360 Always yields true. Does not examine any directories
360 361 or files in the directory structure below the pattern
361 362 just matched. (See EXAMPLES). If -depth is specified,
362 363 -prune has no effect.
363 364
364 365
365 366 -regex pattern
366 367 True if the full path of the file matches pattern
367 368 using regular expressions.
368 369
369 370
370 371 -size n[c]
371 372 True if the file is n blocks long (512 bytes per
372 373 block). If n is followed by a c, the size is in bytes.
373 374
374 375
375 376 -type c
376 377 True if the type of the file is c, where c is b, c, d,
377 378 D, f, l, p, or s for block special file, character
378 379 special file, directory, door, plain file, symbolic
379 380 link, fifo (named pipe), or socket, respectively.
380 381
381 382
382 383 -user uname
383 384 True if the file belongs to the user uname. If uname
384 385 is numeric and there's no such user name, it is taken
385 386 as a user ID.
386 387
387 388
388 389 -useracl uname
389 390 True if the file's ACL contains an entry for the user
390 391 uname. If uname is numeric and there's no such user
391 392 name, it is taken as a user ID.
392 393
393 394
394 395 -xdev
395 396 Same as the -mount primary.
396 397
397 398
398 399 -xattr
399 400 True if the file has extended attributes.
400 401
401 402
402 403 Complex Expressions
403 404 The primaries can be combined using the following operators (in order
404 405 of decreasing precedence):
405 406
406 407 1)(expression)
407 408
408 409 True if the parenthesized expression is true (parentheses are
409 410 special to the shell and must be escaped).
410 411
411 412
412 413 2)!expression
413 414
414 415 The negation of a primary (! is the unary not operator).
415 416
416 417
417 418 3) expression[-a] expression
418 419
419 420 Concatenation of primaries (the and operation is implied by the
420 421 juxtaposition of two primaries).
421 422
422 423
423 424 4) expression-oexpression
424 425
425 426 Alternation of primaries (-o is the or operator).
426 427
427 428
428 429
429 430 When you use find in conjunction with cpio, if you use the -L option
430 431 with cpio, you must use the -L option or the -follow primitive with
431 432 find and vice versa. Otherwise the results are unspecified.
432 433
433 434
434 435 If no expression is present, -print is used as the expression.
435 436 Otherwise, if the specified expression does not contain any of the
436 437 primaries -exec, -ok, -ls, or -print, the specified expression is
437 438 effectively replaced by:
438 439
439 440
440 441 (specified) -print
441 442
442 443
443 444 The -user, -group, and -newer primaries each evaluate their respective
444 445 arguments only once. Invocation of command specified by -exec or -ok
445 446 does not affect subsequent primaries on the same file.
446 447
447 448 USAGE
448 449 See largefile(5) for the description of the behavior of find when
449 450 encountering files greater than or equal to 2 Gbyte (2^31 bytes).
450 451
451 452 EXAMPLES
452 453 Example 1 Writing Out the Hierarchy Directory
453 454
454 455
455 456 The following commands are equivalent:
456 457
457 458
458 459 example% find .
459 460 example% find . -print
460 461
461 462
462 463
463 464
464 465 They both write out the entire directory hierarchy from the current
465 466 directory.
466 467
467 468
468 469 Example 2 Removing Files
469 470
470 471
471 472 The following command removes all files in your home directory named
472 473 a.out or *.o that have not been accessed for a week:
473 474
474 475
475 476 example% find $HOME \( -name a.out -o -name '*.o' \) \
476 477 -atime +7 -exec rm {} \;
477 478
478 479
479 480
480 481 Example 3 Printing All File Names But Skipping SCCS Directories
481 482
482 483
483 484 The following command recursively print all file names in the current
484 485 directory and below, but skipping SCCS directories:
485 486
486 487
487 488 example% find . -name SCCS -prune -o -print
488 489
489 490
490 491
491 492 Example 4 Printing all file names and the SCCS directory name
492 493
493 494
494 495 Recursively print all file names in the current directory and below,
495 496 skipping the contents of SCCS directories, but printing out the SCCS
496 497 directory name:
497 498
498 499
499 500 example% find . -print -name SCCS -prune
500 501
501 502
502 503
503 504 Example 5 Testing for the Newer File
504 505
505 506
506 507 The following command is basically equivalent to the -nt extension to
507 508 test(1):
508 509
509 510
510 511 example$ if [ -n "$(find
511 512 file1 -prune -newer file2)" ]; then
512 513
513 514 printf %s\\n "file1 is newer than file2"
514 515
515 516
516 517
517 518 Example 6 Selecting a File Using 24-hour Mode
518 519
519 520
520 521 The descriptions of -atime, -ctime, and -mtime use the terminology n
521 522 ``24-hour periods''. For example, a file accessed at 23:59 is selected
522 523 by:
523 524
524 525
525 526 example% find . -atime -1 -print
526 527
527 528
528 529
529 530
530 531 at 00:01 the next day (less than 24 hours later, not more than one day
531 532 ago). The midnight boundary between days has no effect on the 24-hour
532 533 calculation.
533 534
534 535
535 536 Example 7 Printing Files Matching a User's Permission Mode
536 537
537 538
538 539 The following command recursively print all file names whose permission
539 540 mode exactly matches read, write, and execute access for user, and read
540 541 and execute access for group and other:
541 542
542 543
543 544 example% find . -perm u=rwx,g=rx,o=rx
544 545
545 546
546 547
547 548
548 549 The above could alternatively be specified as follows:
549 550
550 551
551 552 example% find . -perm a=rwx,g-w,o-w
552 553
553 554
554 555
555 556 Example 8 Printing Files with Write Access for other
556 557
557 558
558 559 The following command recursively print all file names whose permission
559 560 includes, but is not limited to, write access for other:
560 561
561 562
562 563 example% find . -perm -o+w
563 564
564 565
565 566
566 567 Example 9 Printing Local Files without Descending Non-local Directories
567 568
568 569 example% find . ! -local -prune -o -print
569 570
570 571
571 572
572 573 Example 10 Printing the Files in the Name Space Possessing Extended
573 574 Attributes
574 575
575 576 example% find . -xattr
576 577
577 578
578 579
579 580 ENVIRONMENT VARIABLES
580 581 See environ(5) for descriptions of the following environment variables
581 582 that affect the execution of find: LANG, LC_ALL, LC_COLLATE, LC_CTYPE,
582 583 LC_MESSAGES, and NLSPATH.
583 584
584 585 PATH
585 586 Determine the location of the utility_name for the -exec and
586 587 -ok primaries.
587 588
588 589
589 590
590 591 Affirmative responses are processed using the extended regular
591 592 expression defined for the yesexpr keyword in the LC_MESSAGES category
592 593 of the user's locale. The locale specified in the LC_COLLATE category
593 594 defines the behavior of ranges, equivalence classes, and multi-
594 595 character collating elements used in the expression defined for
595 596 yesexpr. The locale specified in LC_CTYPE determines the locale for
596 597 interpretation of sequences of bytes of text data a characters, the
597 598 behavior of character classes used in the expression defined for the
598 599 yesexpr. See locale(5).
599 600
600 601 EXIT STATUS
601 602 The following exit values are returned:
602 603
603 604 0
604 605 All path operands were traversed successfully.
605 606
606 607
607 608 >0
608 609 An error occurred.
609 610
610 611
611 612 FILES
612 613 /etc/passwd
613 614 Password file
614 615
615 616
616 617 /etc/group
617 618 Group file
618 619
619 620
620 621 /etc/dfs/fstypes
621 622 File that registers distributed file system
622 623 packages
623 624
624 625
625 626 ATTRIBUTES
626 627 See attributes(5) for descriptions of the following attributes:
627 628
628 629
629 630
630 631
631 632 +--------------------+-------------------+
632 633 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
633 634 +--------------------+-------------------+
634 635 |CSI | Enabled |
635 636 +--------------------+-------------------+
636 637 |Interface Stability | Committed |
637 638 +--------------------+-------------------+
638 639 |Standard | See standards(5). |
639 640 +--------------------+-------------------+
640 641
641 642 SEE ALSO
642 643 chmod(1), cpio(1), sh(1), test(1), ls(1B), acl(5), regex(5), stat(2),
643 644 umask(2), attributes(5), environ(5), fsattr(5), largefile(5),
644 645 locale(5), standards(5)
645 646
646 647 WARNINGS
647 648 The following options are obsolete and will not be supported in future
648 649 releases:
649 650
650 651 -cpio device
651 652 Always true. Writes the current file on device in cpio
652 653 format (5120-byte records).
653 654
654 655
655 656 -ncpio device
656 657 Always true. Writes the current file on device in cpio
657 658 -c format (5120-byte records).
658 659
659 660
660 661 NOTES
661 662 When using find to determine files modified within a range of time, use
662 663 the -mtime argument before the -print argument. Otherwise, find gives
663 664 all files.
664 665
665 666
666 667 Some files that might be under the Solaris root file system are
667 668 actually mount points for virtual file systems, such as mntfs or
668 669 namefs. When comparing against a ufs file system, such files are not
669 670 selected if -mount or -xdev is specified in the find expression.
670 671
671 672
672 673 Using the -L or -follow option is not recommended when descending a
↓ open down ↓ |
363 lines elided |
↑ open up ↑ |
673 674 file-system hierarchy that is under the control of other users. In
674 675 particular, when using -exec, symbolic links can lead the find command
675 676 out of the hierarchy in which it started. Using -type is not sufficient
676 677 to restrict the type of files on which the -exec command operates,
677 678 because there is an inherent race condition between the type-check
678 679 performed by the find command and the time the executed command
679 680 operates on the file argument.
680 681
681 682
682 683
683 - September 5, 2011 FIND(1)
684 + February 20, 2020 FIND(1)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX