Print this page
9842 man page typos and spelling
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.
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 299 just basename.
300 300
301 301
302 302 -perm [-]mode
303 303 The mode argument is used to represent file mode bits.
304 304 It is identical in format to the symbolic mode
305 305 operand, symbolic_mode_list, described in chmod(1),
306 306 and is interpreted as follows. To start, a template is
307 307 assumed with all file mode bits cleared. An op symbol
308 308 of:
309 309
310 310 +
311 311 Set the appropriate mode bits in the template
312 312
313 313
314 314 -
315 315 Clear the appropriate bits
316 316
317 317
318 318 =
319 319 Set the appropriate mode bits, without regard
320 320 to the contents of the file mode creation mask
321 321 of the process
322 322
323 323 The op symbol of - cannot be the first character of
324 324 mode, to avoid ambiguity with the optional leading
325 325 hyphen. Since the initial mode is all bits off, there
326 326 are no symbolic modes that need to use - as the first
327 327 character.
328 328
329 329 If the hyphen is omitted, the primary evaluates as
330 330 true when the file permission bits exactly match the
331 331 value of the resulting template.
332 332
333 333 Otherwise, if mode is prefixed by a hyphen, the
334 334 primary evaluates as true if at least all the bits in
335 335 the resulting template are set in the file permission
336 336 bits.
337 337
338 338
339 339 -perm [-]onum
340 340 True if the file permission flags exactly match the
341 341 octal number onum (see chmod(1)). If onum is prefixed
342 342 by a minus sign (-), only the bits that are set in
343 343 onum are compared with the file permission flags, and
344 344 the expression evaluates true if they match.
345 345
346 346
347 347 -print
348 348 Always true. Causes the current pathname to be
349 349 printed.
350 350
351 351
352 352 -print0
353 353 Always true. Causes the current pathname to be
354 354 printed, terminated by an ASCII NUL character
355 355 (character code 0) instead of a newline.
356 356
357 357
358 358 -prune
359 359 Always yields true. Does not examine any directories
360 360 or files in the directory structure below the pattern
361 361 just matched. (See EXAMPLES). If -depth is specified,
362 362 -prune has no effect.
363 363
364 364
365 365 -regex pattern
366 366 True if the full path of the file matches pattern
367 367 using regular expressions.
368 368
369 369
370 370 -size n[c]
371 371 True if the file is n blocks long (512 bytes per
372 372 block). If n is followed by a c, the size is in bytes.
373 373
374 374
375 375 -type c
376 376 True if the type of the file is c, where c is b, c, d,
377 377 D, f, l, p, or s for block special file, character
378 378 special file, directory, door, plain file, symbolic
379 379 link, fifo (named pipe), or socket, respectively.
380 380
381 381
382 382 -user uname
383 383 True if the file belongs to the user uname. If uname
384 384 is numeric and there's no such user name, it is taken
385 385 as a user ID.
386 386
387 387
388 388 -useracl uname
389 389 True if the file's ACL contains an entry for the user
390 390 uname. If uname is numeric and there's no such user
391 391 name, it is taken as a user ID.
392 392
393 393
394 394 -xdev
395 395 Same as the -mount primary.
396 396
397 397
398 398 -xattr
399 399 True if the file has extended attributes.
400 400
401 401
402 402 Complex Expressions
403 403 The primaries can be combined using the following operators (in order
404 404 of decreasing precedence):
405 405
406 406 1)(expression)
407 407
408 408 True if the parenthesized expression is true (parentheses are
409 409 special to the shell and must be escaped).
410 410
411 411
412 412 2)!expression
413 413
414 414 The negation of a primary (! is the unary not operator).
415 415
416 416
417 417 3) expression[-a] expression
418 418
419 419 Concatenation of primaries (the and operation is implied by the
420 420 juxtaposition of two primaries).
421 421
422 422
423 423 4) expression-oexpression
424 424
425 425 Alternation of primaries (-o is the or operator).
426 426
427 427
428 428
429 429 When you use find in conjunction with cpio, if you use the -L option
430 430 with cpio, you must use the -L option or the -follow primitive with
431 431 find and vice versa. Otherwise the results are unspecified.
432 432
433 433
434 434 If no expression is present, -print is used as the expression.
435 435 Otherwise, if the specified expression does not contain any of the
436 436 primaries -exec, -ok, -ls, or -print, the specified expression is
437 437 effectively replaced by:
438 438
439 439
440 440 (specified) -print
441 441
442 442
443 443 The -user, -group, and -newer primaries each evaluate their respective
444 444 arguments only once. Invocation of command specified by -exec or -ok
445 445 does not affect subsequent primaries on the same file.
446 446
447 447 USAGE
448 448 See largefile(5) for the description of the behavior of find when
449 449 encountering files greater than or equal to 2 Gbyte (2^31 bytes).
450 450
451 451 EXAMPLES
452 452 Example 1 Writing Out the Hierarchy Directory
453 453
454 454
455 455 The following commands are equivalent:
456 456
457 457
458 458 example% find .
459 459 example% find . -print
460 460
↓ open down ↓ |
460 lines elided |
↑ open up ↑ |
461 461
462 462
463 463
464 464 They both write out the entire directory hierarchy from the current
465 465 directory.
466 466
467 467
468 468 Example 2 Removing Files
469 469
470 470
471 - The following comand removes all files in your home directory named
471 + The following command removes all files in your home directory named
472 472 a.out or *.o that have not been accessed for a week:
473 473
474 474
475 475 example% find $HOME \( -name a.out -o -name '*.o' \) \
476 476 -atime +7 -exec rm {} \;
477 477
478 478
479 479
480 480 Example 3 Printing All File Names But Skipping SCCS Directories
481 481
482 482
483 483 The following command recursively print all file names in the current
484 484 directory and below, but skipping SCCS directories:
485 485
486 486
487 487 example% find . -name SCCS -prune -o -print
488 488
489 489
490 490
491 491 Example 4 Printing all file names and the SCCS directory name
492 492
493 493
494 494 Recursively print all file names in the current directory and below,
495 495 skipping the contents of SCCS directories, but printing out the SCCS
496 496 directory name:
497 497
498 498
499 499 example% find . -print -name SCCS -prune
500 500
501 501
502 502
503 503 Example 5 Testing for the Newer File
504 504
505 505
506 506 The following command is basically equivalent to the -nt extension to
507 507 test(1):
508 508
509 509
510 510 example$ if [ -n "$(find
511 511 file1 -prune -newer file2)" ]; then
512 512
513 513 printf %s\\n "file1 is newer than file2"
514 514
515 515
516 516
517 517 Example 6 Selecting a File Using 24-hour Mode
518 518
519 519
520 520 The descriptions of -atime, -ctime, and -mtime use the terminology n
521 521 ``24-hour periods''. For example, a file accessed at 23:59 is selected
522 522 by:
523 523
524 524
525 525 example% find . -atime -1 -print
526 526
527 527
528 528
529 529
530 530 at 00:01 the next day (less than 24 hours later, not more than one day
531 531 ago). The midnight boundary between days has no effect on the 24-hour
532 532 calculation.
533 533
534 534
535 535 Example 7 Printing Files Matching a User's Permission Mode
536 536
537 537
538 538 The following command recursively print all file names whose permission
539 539 mode exactly matches read, write, and execute access for user, and read
540 540 and execute access for group and other:
541 541
542 542
543 543 example% find . -perm u=rwx,g=rx,o=rx
544 544
545 545
546 546
547 547
548 548 The above could alternatively be specified as follows:
549 549
550 550
551 551 example% find . -perm a=rwx,g-w,o-w
552 552
553 553
554 554
555 555 Example 8 Printing Files with Write Access for other
556 556
557 557
558 558 The following command recursively print all file names whose permission
559 559 includes, but is not limited to, write access for other:
560 560
561 561
562 562 example% find . -perm -o+w
563 563
564 564
565 565
566 566 Example 9 Printing Local Files without Descending Non-local Directories
567 567
568 568 example% find . ! -local -prune -o -print
569 569
570 570
571 571
572 572 Example 10 Printing the Files in the Name Space Possessing Extended
573 573 Attributes
574 574
575 575 example% find . -xattr
576 576
577 577
578 578
579 579 ENVIRONMENT VARIABLES
580 580 See environ(5) for descriptions of the following environment variables
581 581 that affect the execution of find: LANG, LC_ALL, LC_COLLATE, LC_CTYPE,
582 582 LC_MESSAGES, and NLSPATH.
583 583
584 584 PATH
585 585 Determine the location of the utility_name for the -exec and
586 586 -ok primaries.
587 587
588 588
589 589
590 590 Affirmative responses are processed using the extended regular
591 591 expression defined for the yesexpr keyword in the LC_MESSAGES category
592 592 of the user's locale. The locale specified in the LC_COLLATE category
593 593 defines the behavior of ranges, equivalence classes, and multi-
594 594 character collating elements used in the expression defined for
595 595 yesexpr. The locale specified in LC_CTYPE determines the locale for
596 596 interpretation of sequences of bytes of text data a characters, the
597 597 behavior of character classes used in the expression defined for the
598 598 yesexpr. See locale(5).
599 599
600 600 EXIT STATUS
601 601 The following exit values are returned:
602 602
603 603 0
604 604 All path operands were traversed successfully.
605 605
606 606
607 607 >0
608 608 An error occurred.
609 609
610 610
611 611 FILES
612 612 /etc/passwd
613 613 Password file
614 614
615 615
616 616 /etc/group
617 617 Group file
618 618
619 619
620 620 /etc/dfs/fstypes
621 621 File that registers distributed file system
622 622 packages
623 623
624 624
625 625 ATTRIBUTES
626 626 See attributes(5) for descriptions of the following attributes:
627 627
628 628
629 629
630 630
631 631 +--------------------+-------------------+
632 632 | ATTRIBUTE TYPE | ATTRIBUTE VALUE |
633 633 +--------------------+-------------------+
634 634 |CSI | Enabled |
635 635 +--------------------+-------------------+
636 636 |Interface Stability | Committed |
637 637 +--------------------+-------------------+
638 638 |Standard | See standards(5). |
639 639 +--------------------+-------------------+
640 640
641 641 SEE ALSO
642 642 chmod(1), cpio(1), sh(1), test(1), ls(1B), acl(5), regex(5), stat(2),
643 643 umask(2), attributes(5), environ(5), fsattr(5), largefile(5),
644 644 locale(5), standards(5)
645 645
646 646 WARNINGS
647 647 The following options are obsolete and will not be supported in future
648 648 releases:
649 649
650 650 -cpio device
651 651 Always true. Writes the current file on device in cpio
652 652 format (5120-byte records).
653 653
654 654
655 655 -ncpio device
656 656 Always true. Writes the current file on device in cpio
657 657 -c format (5120-byte records).
658 658
659 659
660 660 NOTES
661 661 When using find to determine files modified within a range of time, use
662 662 the -mtime argument before the -print argument. Otherwise, find gives
663 663 all files.
664 664
665 665
666 666 Some files that might be under the Solaris root file system are
667 667 actually mount points for virtual file systems, such as mntfs or
668 668 namefs. When comparing against a ufs file system, such files are not
669 669 selected if -mount or -xdev is specified in the find expression.
670 670
671 671
672 672 Using the -L or -follow option is not recommended when descending a
673 673 file-system hierarchy that is under the control of other users. In
674 674 particular, when using -exec, symbolic links can lead the find command
675 675 out of the hierarchy in which it started. Using -type is not sufficient
676 676 to restrict the type of files on which the -exec command operates,
677 677 because there is an inherent race condition between the type-check
678 678 performed by the find command and the time the executed command
679 679 operates on the file argument.
680 680
681 681
682 682
683 683 September 5, 2011 FIND(1)
↓ open down ↓ |
202 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX