summaryrefslogtreecommitdiff
path: root/usr/src/man/man1/find.1
blob: 47f3870d12908d0f58ea8ccc7b6aaada58dcecde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
.\"
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
.\" permission to reproduce portions of its copyrighted documentation.
.\" Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
.\"
.\" The Institute of Electrical and Electronics Engineers and The Open
.\" Group, have given us permission to reprint portions of their
.\" documentation.
.\"
.\" In the following statement, the phrase ``this text'' refers to portions
.\" of the system documentation.
.\"
.\" Portions of this text are reprinted and reproduced in electronic form
.\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
.\" Standard for Information Technology -- Portable Operating System
.\" Interface (POSIX), The Open Group Base Specifications Issue 6,
.\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
.\" Engineers, Inc and The Open Group.  In the event of any discrepancy
.\" between these versions and the original IEEE and The Open Group
.\" Standard, the original IEEE and The Open Group Standard is the referee
.\" document.  The original Standard can be obtained online at
.\" http://www.opengroup.org/unix/online.html.
.\"
.\" This notice shall appear on any product containing this material.
.\"
.\" The contents of this file are subject to the terms of the
.\" Common Development and Distribution License (the "License").
.\" You may not use this file except in compliance with the License.
.\"
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
.\" or http://www.opensolaris.org/os/licensing.
.\" See the License for the specific language governing permissions
.\" and limitations under the License.
.\"
.\" When distributing Covered Code, include this CDDL HEADER in each
.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
.\" If applicable, add the following below this CDDL HEADER, with the
.\" fields enclosed by brackets "[]" replaced with your own identifying
.\" information: Portions Copyright [yyyy] [name of copyright owner]
.\"
.\"
.\" Copyright 1989 AT&T
.\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
.\" Copyright 2011 Nexenta Systems, Inc. All rights reserved.
.\" Copyright (c) 2013 Andrew Stormont.  All rights reserved.
.\"
.TH FIND 1 "Sep 5, 2011"
.SH NAME
find \- find files
.SH SYNOPSIS
.LP
.nf
\fB/usr/bin/find\fR [\fB-E\fR] [\fB-H\fR | \fB-L\fR] \fIpath\fR... \fIexpression\fR
.fi

.LP
.nf
\fB/usr/xpg4/bin/find\fR [\fB-H\fR | \fB-L\fR] \fIpath\fR... \fIexpression\fR
.fi

.SH DESCRIPTION
.LP
The \fBfind\fR utility recursively descends the directory hierarchy for each
\fIpath\fR seeking files that match a Boolean \fIexpression\fR written in the
primaries specified below.
.sp
.LP
\fBfind\fR is able to descend to arbitrary depths in a file hierarchy and does
not fail due to path length limitations (unless a \fIpath\fR operand specified
by the application exceeds \fIPATH_MAX\fR requirements).
.sp
.LP
\fBfind\fR detects infinite loops; that is, entering a previously visited
directory that is an ancestor of the last file encountered.
.SH OPTIONS
.LP
The following options are supported:
.sp
.ne 2
.na
\fB\fB-E\fR\fR
.ad
.RS 6n
Interpret regular expressions followed by \fB-regex\fR and \fB-iregex\fR
primaries as extended regular expressions.
.RE

.sp
.ne 2
.na
\fB\fB-H\fR\fR
.ad
.RS 6n
Causes the file information and file type evaluated for each symbolic link
encountered on the command line to be those of the file referenced by the link,
and not the link itself. If the referenced file does not exist, the file
information and type is for the link itself. File information for all symbolic
links not on the command line is that of the link itself.
.RE

.sp
.ne 2
.na
\fB\fB-L\fR\fR
.ad
.RS 6n
Causes the file information and file type evaluated for each symbolic link to
be those of the file referenced by the link, and not the link itself. See
\fBNOTES\fR.
.RE

.sp
.LP
Specifying more than one of the mutually-exclusive options \fB-H\fR and
\fB-L\fR is not considered an error. The last option specified determines the
behavior of the utility.
.SH OPERANDS
.LP
The following operands are supported:
.sp
.ne 2
.na
\fB\fIpath\fR\fR
.ad
.RS 14n
A pathname of a starting point in the directory hierarchy.
.RE

.sp
.ne 2
.na
\fB\fIexpression\fR\fR
.ad
.RS 14n
The first argument that starts with a \fB\(mi\fR, or is a \fB!\fR or a \fB(\fR,
and all subsequent arguments are interpreted as an \fIexpression\fR made up of
the following primaries and operators. In the descriptions, wherever \fIn\fR is
used as a primary argument, it is interpreted as a decimal integer optionally
preceded by a plus (\fB+\fR) or minus (\fB\(mi\fR) sign, as follows:
.sp
.ne 2
.na
\fB+\fIn\fR\fR
.ad
.RS 6n
more than \fIn\fR
.RE

.sp
.ne 2
.na
\fB\fIn\fR\fR
.ad
.RS 6n
exactly \fIn\fR
.RE

.sp
.ne 2
.na
\fB-\fIn\fR\fR
.ad
.RS 6n
less than \fIn\fR
.RE

.RE

.SS "Expressions"
.LP
Valid expressions are:
.sp
.ne 2
.na
\fB\fB-acl\fR\fR
.ad
.RS 17n
True if the file have additional ACLs defined.
.RE

.sp
.ne 2
.na
\fB\fB-amin\fR \fIn\fR\fR
.ad
.RS 17n
File was last accessed \fIn\fR minutes ago.
.RE

.sp
.ne 2
.na
\fB\fB-atime\fR \fIn\fR\fR
.ad
.RS 17n
True if the file was accessed \fIn\fR days ago. The access time of directories
in \fIpath\fR is changed by \fBfind\fR itself.
.RE

.sp
.ne 2
.na
\fB\fB-cmin\fR \fIn\fR\fR
.ad
.RS 17n
File's status was last changed \fIn\fR minutes ago.
.RE

.sp
.ne 2
.na
\fB\fB-cpio\fR \fIdevice\fR\fR
.ad
.RS 17n
Always true. Writes the current file on \fIdevice\fR in \fBcpio\fR format
(5120-byte records).
.RE

.sp
.ne 2
.na
\fB\fB-ctime\fR \fIn\fR\fR
.ad
.RS 17n
True if the file's status was changed \fIn\fR days ago.
.RE

.sp
.ne 2
.na
\fB\fB-depth\fR\fR
.ad
.RS 17n
Always true. Causes descent of the directory hierarchy to be done so that all
entries in a directory are acted on before the directory itself. This can be
useful when \fBfind\fR is used with \fBcpio\fR(1) to transfer files that are
contained in directories without write permission.
.RE

.sp
.ne 2
.na
\fB\fB-exec\fR \fIcommand\fR\fR
.ad
.RS 17n
True if the executed command returns a zero value as exit status. The end of
command must be punctuated by an escaped semicolon (\fB;\fR). A command
argument \fB{}\fR is replaced by the current pathname. If the last argument to
\fB-exec\fR is \fB{}\fR and you specify \fB+\fR rather than the semicolon
(\fB;\fR), the command is invoked fewer times, with \fB{}\fR replaced by groups
of pathnames. If any invocation of the command returns a non-zero value as exit
status, find returns a non-zero exit status.
.RE

.sp
.ne 2
.na
\fB\fB-follow\fR\fR
.ad
.RS 17n
Always true and always evaluated no matter where it appears in
\fIexpression\fR. The behavior is unspecified if \fB-follow\fR is used when the
\fBfind\fR command is invoked with either the \fB-H\fR or the \fB-L\fR option.
Causes symbolic links to be followed. When following symbolic links, \fBfind\fR
keeps track of the directories visited so that it can detect infinite loops.
For example, such a loop would occur if a symbolic link pointed to an ancestor.
This expression should not be used with the find-type \fBl\fR expression. See
\fBNOTES\fR.
.RE

.sp
.ne 2
.na
\fB\fB-fstype\fR \fItype\fR\fR
.ad
.RS 17n
True if the filesystem to which the file belongs is of type \fItype\fR.
.RE

.sp
.ne 2
.na
\fB\fB-group\fR \fIgname\fR\fR
.ad
.RS 17n
True if the file belongs to the group \fIgname\fR. If \fIgname\fR is numeric
and there's no such group name, it is taken as a group \fBID\fR.
.RE

.sp
.ne 2
.na
\fB\fB-groupacl\fR \fIgname\fR\fR
.ad
.RS 17n
True if the file's ACL contains an entry for the group \fIgname\fR.
If \fIgname\fR is numeric and there's no such group name, it is taken
as a group \fBID\fR.
.RE

.sp
.ne 2
.na
\fB\fB-iname\fR \fIpattern\fR\fR
.ad
.RS 17n
Like \fB-name\fR, but the match is case insensitive.
.RE

.sp
.ne 2
.na
\fB\fB-inum\fR \fIn\fR\fR
.ad
.RS 17n
True if the file has inode number \fIn\fR.
.RE

.sp
.ne 2
.na
\fB\fB-ipath\fR \fIpattern\fR\fR
.ad
.RS 17n
Like \fB-path\fR, but the match is case insensitive.
.RE

.sp
.ne 2
.na
\fB\fB-iregex\fR \fIpattern\fR\fR
.ad
.RS 17n
Like \fB-regex\fR, but the match is case insensitive.
.RE

.sp
.ne 2
.na
\fB\fB-links\fR \fIn\fR\fR
.ad
.RS 17n
True if the file has \fIn\fR links.
.RE

.sp
.ne 2
.na
\fB\fB-local\fR\fR
.ad
.RS 17n
True if the file system type is not a remote file system type as defined in the
\fB/etc/dfs/fstypes\fR file. \fBnfs\fR is used as the default remote filesystem
type if the \fB/etc/dfs/fstypes\fR file is not present. The \fB-local\fR option
descends the hierarchy of non-local directories. See \fBEXAMPLES\fR for an
example of how to search for local files without descending.
.RE

.sp
.ne 2
.na
\fB\fB-ls\fR\fR
.ad
.RS 17n
Always true. Prints current pathname together with its associated statistics.
These include (respectively):
.RS +4
.TP
.ie t \(bu
.el o
inode number
.RE
.RS +4
.TP
.ie t \(bu
.el o
size in kilobytes (1024 bytes)
.RE
.RS +4
.TP
.ie t \(bu
.el o
protection mode
.RE
.RS +4
.TP
.ie t \(bu
.el o
number of hard links
.RE
.RS +4
.TP
.ie t \(bu
.el o
user
.RE
.RS +4
.TP
.ie t \(bu
.el o
group
.RE
.RS +4
.TP
.ie t \(bu
.el o
size in bytes
.RE
.RS +4
.TP
.ie t \(bu
.el o
modification time.
.RE
If the file is a special file, the size field instead contains the major and
minor device numbers.
.sp
If the file is a symbolic link, the pathname of the linked-to file is printed
preceded by `\fB\(->\fR\&'. The format is identical to that of \fBls\fR
\fB-gilds\fR (see \fBls\fR(1B)).
.sp
Formatting is done internally, without executing the \fBls\fR program.
.RE

.sp
.ne 2
.na
\fB\fB-maxdepth\fR \fIn\fR\fR
.ad
.RS 17n
Always true; descend at most \fIn\fR directory levels below the command
line arguments. If any \fB-maxdepth\fR primary is specified, it
applies to the entire expression even if it would not normally be
evaluated. \fB-maxdepth 0\fR limits the whole search to
the command line arguments.
.RE

.sp
.ne 2
.na
\fB\fB-mindepth\fR \fIn\fR\fR
.ad
.RS 17n
Always true; do not apply any tests or actions at levels less
than \fIn\fR. If any \fB-mindepth\fR primary is specified, it applies to the
entire expression even if it would not normally be evaluated.
\fB-mindepth 1\fR processes all but the command line arguments.
.RE

.sp
.ne 2
.na
\fB\fB-mmin\fR \fIn\fR\fR
.ad
.RS 17n
File's data was last modified \fIn\fR minutes ago.
.RE

.sp
.ne 2
.na
\fB\fB-mount\fR\fR
.ad
.RS 17n
Always true. Restricts the search to the file system containing the directory
specified. Does not list mount points to other file systems.
.RE

.sp
.ne 2
.na
\fB\fB-mtime\fR \fIn\fR\fR
.ad
.RS 17n
True if the file's data was modified \fIn\fR days ago.
.RE

.sp
.ne 2
.na
\fB\fB-name\fR \fIpattern\fR\fR
.ad
.RS 17n
True if \fIpattern\fR matches the basename of the current file name. Normal
shell file name generation characters (see \fBsh\fR(1)) can be used. A
backslash (\fB\|\e\|\fR) is used as an escape character within the pattern. The
pattern should be escaped or quoted when \fBfind\fR is invoked from the shell.
.sp
Unless the character '\fB\&.\fR' is explicitly specified in the beginning of
\fIpattern\fR, a current file name beginning with '\fB\&.\fR' does not match
\fIpattern\fR when using \fB/usr/bin/find\fR. \fB/usr/xpg4/bin/find\fR does not
make this distinction; wildcard file name generation characters can match file
names beginning with '\fB\&.\fR'.
.RE

.sp
.ne 2
.na
\fB\fB-ncpio\fR \fIdevice\fR\fR
.ad
.RS 17n
Always true. Writes the current file on \fIdevice\fR in \fBcpio\fR \fB-c\fR
format (5120 byte records).
.RE

.sp
.ne 2
.na
\fB\fB-newer\fR \fIfile\fR\fR
.ad
.RS 17n
True if the current file has been modified more recently than the argument
\fIfile\fR.
.RE

.sp
.ne 2
.na
\fB\fB-nogroup\fR\fR
.ad
.RS 17n
True if the file belongs to non-existing group.
.RE

.sp
.ne 2
.na
\fB\fB-nouser\fR\fR
.ad
.RS 17n
True if the file belongs to non-existing user.
.RE

.sp
.ne 2
.na
\fB\fB-ok\fR \fIcommand\fR\fR
.ad
.RS 17n
Like \fB-exec\fR, except that the generated command line is printed with a
question mark first, and is executed only if the response is affirmative.
.RE

.sp
.ne 2
.na
\fB\fB-path\fR\fR
.ad
.RS 17n
Like \fB-name\fR, but matches the entire file path and not just basename.
.RE

.sp
.ne 2
.na
\fB\fB-perm\fR [\fB-\fR]\fImode\fR\fR
.ad
.RS 17n
The \fImode\fR argument is used to represent file mode bits. It is identical in
format to the symbolic mode operand, \fIsymbolic_mode_list\fR, described in
\fBchmod\fR(1), and is interpreted as follows. To start, a template is assumed
with all file mode bits cleared. An \fIop\fR symbol of:
.sp
.ne 2
.na
\fB\fB+\fR\fR
.ad
.RS 8n
Set the appropriate mode bits in the template
.RE

.sp
.ne 2
.na
\fB\fB\(mi\fR\fR
.ad
.RS 8n
Clear the appropriate bits
.RE

.sp
.ne 2
.na
\fB\fB=\fR\fR
.ad
.RS 8n
Set the appropriate mode bits, without regard to the contents of the file mode
creation mask of the process
.RE

The \fIop\fR symbol of \fB\(mi\fR cannot be the first character of \fImode\fR,
to avoid ambiguity with the optional leading hyphen. Since the initial mode is
all bits off, there are no symbolic modes that need to use \fB\(mi\fR as the
first character.
.sp
If the hyphen is omitted, the primary evaluates as true when the file
permission bits exactly match the value of the resulting template.
.sp
Otherwise, if \fImode\fR is prefixed by a hyphen, the primary evaluates as true
if at least all the bits in the resulting template are set in the file
permission bits.
.RE

.sp
.ne 2
.na
\fB\fB-perm\fR [\fB-\fR]\fIonum\fR\fR
.ad
.RS 17n
True if the file permission flags exactly match the octal number \fIonum\fR
(see \fBchmod\fR(1)). If \fIonum\fR is prefixed by a minus sign (\fB\(mi\fR),
only the bits that are set in \fIonum\fR are compared with the file permission
flags, and the expression evaluates true if they match.
.RE

.sp
.ne 2
.na
\fB\fB-print\fR\fR
.ad
.RS 17n
Always true. Causes the current pathname to be printed.
.RE

.sp
.ne 2
.na
\fB\fB-print0\fR\fR
.ad
.RS 17n
Always true. Causes the current pathname to be printed, terminated by an ASCII
NUL character (character code 0) instead of a newline.
.RE

.sp
.ne 2
.na
\fB\fB-prune\fR\fR
.ad
.RS 17n
Always yields true. Does not examine any directories or files in the directory
structure below the \fIpattern\fR just matched. (See EXAMPLES). If \fB-depth\fR
is specified, \fB-prune\fR has no effect.
.RE

.sp
.ne 2
.na
\fB\fB-regex\fR \fIpattern\fR\fB
.ad
.RS 17n
True if the full path of the file matches \fIpattern\fR using regular
expressions.
.RE

.sp
.ne 2
.na
\fB\fB-size\fR \fIn\fR[\fBc\fR]\fR
.ad
.RS 17n
True if the file is \fIn\fR blocks long (512 bytes per block). If \fIn\fR is
followed by a \fBc\fR, the size is in bytes.
.RE

.sp
.ne 2
.na
\fB\fB-type\fR \fIc\fR\fR
.ad
.RS 17n
True if the type of the file is \fIc\fR, where \fIc\fR is \fBb\fR, \fBc\fR,
\fBd\fR, \fBD\fR, \fBf\fR, \fBl\fR, \fBp\fR, or \fBs\fR for block special file,
character special file, directory, door, plain file, symbolic link, fifo (named
pipe), or socket, respectively.
.RE

.sp
.ne 2
.na
\fB\fB-user\fR \fIuname\fR\fR
.ad
.RS 17n
True if the file belongs to the user \fIuname\fR. If \fIuname\fR is numeric and
there's no such user name, it is taken as a user \fBID\fR.
.RE

.sp
.ne 2
.na
\fB\fB-useracl\fR \fIuname\fR\fR
.ad
.RS 17n
True if the file's ACL contains an entry for the user \fIuname\fR.
If \fIuname\fR is numeric and there's no such user name, it is
taken as a user \fBID\fR.
.RE

.sp
.ne 2
.na
\fB\fB-xdev\fR\fR
.ad
.RS 17n
Same as the \fB-mount\fR primary.
.RE

.sp
.ne 2
.na
\fB\fB-xattr\fR\fR
.ad
.RS 17n
True if the file has extended attributes.
.RE

.SS "Complex Expressions"
.LP
The primaries can be combined using the following operators (in order of
decreasing precedence):
.sp
.ne 2
.na
\fB1)\fB(\fR\fIexpression\fR\fB)\fR\fR
.ad
.sp .6
.RS 4n
True if the parenthesized expression is true (parentheses are special to the
shell and must be escaped).
.RE

.sp
.ne 2
.na
\fB2)\fB!\fR\fIexpression\fR\fR
.ad
.sp .6
.RS 4n
The negation of a primary (\fB!\fR is the unary \fInot\fR operator).
.RE

.sp
.ne 2
.na
\fB3) \fIexpression\fR\fB[\fR\fB-a\fR\fB]\fR \fIexpression\fR\fR
.ad
.sp .6
.RS 4n
Concatenation of primaries (the \fIand\fR operation is implied by the
juxtaposition of two primaries).
.RE

.sp
.ne 2
.na
\fB4) \fIexpression\fR\fB\fR\fB-o\fR\fIexpression\fR\fR
.ad
.sp .6
.RS 4n
Alternation of primaries (\fB-o\fR is the \fIor\fR operator).
.RE

.sp
.LP
When you use \fBfind\fR in conjunction with \fBcpio\fR, if you use the \fB-L\fR
option with \fBcpio\fR, you must use the \fB-L\fR option or the \fB-follow\fR
primitive with \fBfind\fR and vice versa. Otherwise the results are
unspecified.
.sp
.LP
If no \fIexpression\fR is present, \fB-print\fR is used as the expression.
Otherwise, if the specified expression does not contain any of the primaries
\fB-exec\fR, \fB-ok\fR, \fB-ls\fR, or \fB-print\fR, the specified expression is
effectively replaced by:
.sp
.LP
(\fIspecified\fR) \fB-print\fR
.sp
.LP
The \fB-user\fR, \fB-group\fR, and \fB-newer\fR primaries each evaluate their
respective arguments only once. Invocation of \fIcommand\fR specified by
\fB-exec\fR or \fB-ok\fR does not affect subsequent primaries on the same file.
.SH USAGE
.LP
See \fBlargefile\fR(5) for the description of the behavior of \fBfind\fR when
encountering files greater than or equal to 2 Gbyte (2^31 bytes).
.SH EXAMPLES
.LP
\fBExample 1 \fRWriting Out the Hierarchy Directory
.sp
.LP
The following commands are equivalent:

.sp
.in +2
.nf
example% \fBfind .\fR
example% \fBfind . -print\fR
.fi
.in -2
.sp

.sp
.LP
They both write out the entire directory hierarchy from the current directory.

.LP
\fBExample 2 \fRRemoving Files
.sp
.LP
The following command removes all files in your home directory named \fBa.out\fR
or \fB*.o\fR that have not been accessed for a week:

.sp
.in +2
.nf
example% \fBfind $HOME \e( -name a.out -o -name '*.o' \e) \e
       -atime +7 -exec rm {} \e;\fR
.fi
.in -2
.sp

.LP
\fBExample 3 \fRPrinting All File Names But Skipping SCCS Directories
.sp
.LP
The following command recursively print all file names in the current directory
and below, but skipping \fBSCCS\fR directories:

.sp
.in +2
.nf
example% \fBfind . -name SCCS -prune -o -print\fR
.fi
.in -2
.sp

.LP
\fBExample 4 \fRPrinting all file names and the SCCS directory name
.sp
.LP
Recursively print all file names in the current directory and below, skipping
the contents of \fBSCCS\fR directories, but printing out the \fBSCCS\fR
directory name:

.sp
.in +2
.nf
example% \fBfind . -print -name SCCS -prune\fR
.fi
.in -2
.sp

.LP
\fBExample 5 \fRTesting for the Newer File
.sp
.LP
The following command is basically equivalent to the \fB-nt\fR extension to
\fBtest\fR(1):

.sp
.in +2
.nf
example$ \fBif [ -n "$(find
file1 -prune -newer file2)" ]; then

printf %s\e\en "file1 is newer than file2"\fR
.fi
.in -2
.sp

.LP
\fBExample 6 \fRSelecting a File Using 24-hour Mode
.sp
.LP
The descriptions of \fB-atime\fR, \fB-ctime\fR, and \fB-mtime\fR use the
terminology \fIn\fR ``24-hour periods''. For example, a file accessed at 23:59
is selected by:

.sp
.in +2
.nf
example% \fBfind . -atime -1 -print\fR
.fi
.in -2
.sp

.sp
.LP
at 00:01 the next day (less than 24 hours later, not more than one day ago).
The midnight boundary between days has no effect on the 24-hour calculation.

.LP
\fBExample 7 \fRPrinting Files Matching a User's Permission Mode
.sp
.LP
The following command recursively print all file names whose permission mode
exactly matches read, write, and execute access for user, and read and execute
access for group and other:

.sp
.in +2
.nf
example% \fBfind . -perm u=rwx,g=rx,o=rx\fR
.fi
.in -2
.sp

.sp
.LP
The above could alternatively be specified as follows:

.sp
.in +2
.nf
example% \fBfind . -perm a=rwx,g-w,o-w\fR
.fi
.in -2
.sp

.LP
\fBExample 8 \fRPrinting Files with Write Access for \fBother\fR
.sp
.LP
The following command recursively print all file names whose permission
includes, but is not limited to, write access for other:

.sp
.in +2
.nf
example% \fBfind . -perm -o+w\fR
.fi
.in -2
.sp

.LP
\fBExample 9 \fRPrinting Local Files without Descending Non-local Directories
.sp
.in +2
.nf
example% \fBfind . ! -local -prune -o -print\fR
.fi
.in -2
.sp

.LP
\fBExample 10 \fRPrinting the Files in the Name Space Possessing Extended
Attributes
.sp
.in +2
.nf
example% \fBfind . -xattr\fR
.fi
.in -2
.sp

.SH ENVIRONMENT VARIABLES
.LP
See \fBenviron\fR(5) for descriptions of the following environment variables
that affect the execution of \fBfind\fR: \fBLANG\fR, \fBLC_ALL\fR,
\fBLC_COLLATE\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
.sp
.ne 2
.na
\fB\fBPATH\fR\fR
.ad
.RS 8n
Determine the location of the \fIutility_name\fR for the \fB-exec\fR and
\fB-ok\fR primaries.
.RE

.sp
.LP
Affirmative responses are processed using the extended regular expression
defined for the \fByesexpr\fR keyword in the \fBLC_MESSAGES\fR category of the
user's locale. The locale specified in the \fBLC_COLLATE\fR category defines
the behavior of ranges, equivalence classes, and multi-character collating
elements used in the expression defined for \fByesexpr\fR. The locale specified
in \fBLC_CTYPE\fR determines the locale for interpretation of sequences of
bytes of text data a characters, the behavior of character classes used in the
expression defined for the \fByesexpr\fR. See \fBlocale\fR(5).
.SH EXIT STATUS
.LP
The following exit values are returned:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
All \fIpath\fR operands were traversed successfully.
.RE

.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
An error occurred.
.RE

.SH FILES
.ne 2
.na
\fB\fB/etc/passwd\fR\fR
.ad
.RS 20n
Password file
.RE

.sp
.ne 2
.na
\fB\fB/etc/group\fR\fR
.ad
.RS 20n
Group file
.RE

.sp
.ne 2
.na
\fB\fB/etc/dfs/fstypes\fR\fR
.ad
.RS 20n
File that registers distributed file system packages
.RE

.SH ATTRIBUTES
.LP
See \fBattributes\fR(5) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
CSI	Enabled
_
Interface Stability	Committed
_
Standard	See \fBstandards\fR(5).
.TE

.SH SEE ALSO
.LP
\fBchmod\fR(1), \fBcpio\fR(1), \fBsh\fR(1), \fBtest\fR(1), \fBls\fR(1B),
\fBacl\fR(5), \fBregex\fR(5), \fBstat\fR(2), \fBumask\fR(2),
\fBattributes\fR(5), \fBenviron\fR(5), \fBfsattr\fR(5), \fBlargefile\fR(5),
\fBlocale\fR(5), \fBstandards\fR(5)
.SH WARNINGS
.LP
The following options are obsolete and will not be supported in future
releases:
.sp
.ne 2
.na
\fB\fB-cpio\fR \fIdevice\fR\fR
.ad
.RS 17n
Always true. Writes the current file on \fIdevice\fR in \fBcpio\fR format
(5120-byte records).
.RE

.sp
.ne 2
.na
\fB\fB-ncpio\fR \fIdevice\fR\fR
.ad
.RS 17n
Always true. Writes the current file on \fIdevice\fR in \fBcpio\fR \fB-c\fR
format (5120-byte records).
.RE

.SH NOTES
.LP
When using \fBfind\fR to determine files modified within a range of time, use
the \fB-mtime\fR argument \fBbefore\fR the \fB-print\fR argument. Otherwise,
\fBfind\fR gives all files.
.sp
.LP
Some files that might be under the Solaris root file system are actually mount
points for virtual file systems, such as \fBmntfs\fR or \fBnamefs\fR. When
comparing against a \fBufs\fR file system, such files are not selected if
\fB-mount\fR or \fB-xdev\fR is specified in the \fBfind\fR expression.
.sp
.LP
Using the \fB-L\fR or \fB-follow\fR option is not recommended when descending a
file-system hierarchy that is under the control of other users. In particular,
when using \fB-exec\fR, symbolic links can lead the \fBfind\fR command out of
the hierarchy in which it started. Using \fB-type\fR is not sufficient to
restrict the type of files on which the \fB-exec\fR command operates, because
there is an inherent race condition between the type-check performed by the
\fBfind\fR command and the time the executed command operates on the file
argument.