Penguin
Annotated edit history of find(1) version 1, including all changes. View license author blame.
Rev Author # Line
1 perry 1 FIND
2 !!!FIND
3 NAME
4 SYNOPSIS
5 DESCRIPTION
6 EXPRESSIONS
7 SEE ALSO
8 ----
9 !!NAME
10
11
12 find - search for files in a directory hierarchy
13 !!SYNOPSIS
14
15
16 __find__ [[path...] [[expression]
17 !!DESCRIPTION
18
19
20 This manual page documents the GNU version of __find__.
21 __find__ searches the directory tree rooted at each given
22 file name by evaluating the given expression from left to
23 right, according to the rules of precedence (see section
24 OPERATORS), until the outcome is known (the left hand side
25 is false for ''and'' operations, true for ''or''), at
26 which point __find__ moves on to the next file
27 name.
28
29
30 The first argument that begins with `-', `(', `)', `,', or
31 `!' is taken to be the beginning of the expression; any
32 arguments before it are paths to search, and any arguments
33 after it are the rest of the expression. If no paths are
34 given, the current directory is used. If no expression is
35 given, the expression `-print' is used.
36
37
38 __find__ exits with status 0 if all files are processed
39 successfully, greater than 0 if errors occur.
40 !!EXPRESSIONS
41
42
43 The expression is made up of options (which affect overall
44 operation rather than the processing of a specific file, and
45 always return true), tests (which return a true or false
46 value), and actions (which have side effects and return a
47 true or false value), all separated by operators. -and is
48 assumed where the operator is omitted. If the expression
49 contains no actions other than -prune, -print is performed
50 on all files for which the expression is true.
51
52
53 __OPTIONS__
54
55
56 All options always return true. They always take effect,
57 rather than being processed only when their place in the
58 expression is reached. Therefore, for clarity, it is best to
59 place them at the beginning of the expression.
60
61
62 -daystart
63
64
65 Measure times (for -amin, -atime, -cmin, -ctime, -mmin, and
66 -mtime) from the beginning of today rather than from 24
67 hours ago.
68
69
70 -depth
71
72
73 Process each directory's contents before the directory
74 itself.
75
76
77 -follow
78
79
80 Dereference symbolic links. Implies -noleaf.
81
82
83 -help, --help
84
85
86 Print a summary of the command-line usage of __find__ and
87 exit.
88
89
90 -maxdepth ''levels''
91
92
93 Descend at most ''levels'' (a non-negative integer)
94 levels of directories below the command line arguments.
95 `-maxdepth 0' means only apply the tests and actions to the
96 command line arguments.
97
98
99 -mindepth ''levels''
100
101
102 Do not apply any tests or actions at levels less than
103 ''levels'' (a non-negative integer). `-mindepth 1' means
104 process all files except the command line
105 arguments.
106
107
108 -mount
109
110
111 Don't descend directories on other filesystems. An alternate
112 name for -xdev, for compatibility with some other versions
113 of __find__.
114
115
116 -noleaf
117
118
119 Do not optimize by assuming that directories contain 2 fewer
120 subdirectories than their hard link count. This option is
121 needed when searching filesystems that do not follow the
122 Unix directory-link convention, such as CD-ROM or MS-DOS
123 filesystems or AFS volume mount points. Each directory on a
124 normal Unix filesystem has at least 2 hard links: its name
125 and its `.' entry. Additionally, its subdirectories (if any)
126 each have a `..' entry linked to that directory. When
127 __find__ is examining a directory, after it has statted 2
128 fewer subdirectories than the directory's link count, it
129 knows that the rest of the entries in the directory are
130 non-directories (`leaf' files in the directory tree). If
131 only the files' names need to be examined, there is no need
132 to stat them; this gives a significant increase in search
133 speed.
134
135
136 -version, --version
137
138
139 Print the __find__ version number and exit.
140
141
142 -xdev
143
144
145 Don't descend directories on other filesystems.
146
147
148 __TESTS__
149
150
151 Numeric arguments can be specified as
152
153
154 ''+n''
155
156
157 for greater than ''n'',
158
159
160 ''-n''
161
162
163 for less than ''n'',
164
165
166 ''n''
167
168
169 for exactly ''n''.
170
171
172 -amin ''n''
173
174
175 File was last accessed ''n'' minutes ago.
176
177
178 -anewer ''file''
179
180
181 File was last accessed more recently than ''file'' was
182 modified. -anewer is affected by -follow only if -follow
183 comes before -anewer on the command line.
184
185
186 -atime ''n''
187
188
189 File was last accessed ''n''*24 hours ago.
190
191
192 -cmin ''n''
193
194
195 File's status was last changed ''n'' minutes
196 ago.
197
198
199 -cnewer ''file''
200
201
202 File's status was last changed more recently than
203 ''file'' was modified. -cnewer is affected by -follow
204 only if -follow comes before -cnewer on the command
205 line.
206
207
208 -ctime ''n''
209
210
211 File's status was last changed ''n''*24 hours
212 ago.
213
214
215 -empty
216
217
218 File is empty and is either a regular file or a
219 directory.
220
221
222 -false
223
224
225 Always false.
226
227
228 -fstype ''type''
229
230
231 File is on a filesystem of type ''type''. The valid
232 filesystem types vary among different versions of Unix; an
233 incomplete list of filesystem types that are accepted on
234 some version of Unix or another is: ufs, 4.2, 4.3, nfs, tmp,
235 mfs, S51K, S52K. You can use -printf with the %F directive
236 to see the types of your filesystems.
237
238
239 -gid ''n''
240
241
242 File's numeric group ID is ''n''.
243
244
245 -group ''gname''
246
247
248 File belongs to group ''gname'' (numeric group ID
249 allowed).
250
251
252 -ilname ''pattern''
253
254
255 Like -lname, but the match is case insensitive.
256
257
258 -iname ''pattern''
259
260
261 Like -name, but the match is case insensitive. For example,
262 the patterns `fo*' and `F??' match the file names `Foo',
263 `FOO', `foo', `fOo', etc.
264
265
266 -inum ''n''
267
268
269 File has inode number ''n''.
270
271
272 -ipath ''pattern''
273
274
275 Like -path, but the match is case insensitive.
276
277
278 -iregex ''pattern''
279
280
281 Like -regex, but the match is case insensitive.
282
283
284 -links ''n''
285
286
287 File has ''n'' links.
288
289
290 -lname ''pattern''
291
292
293 File is a symbolic link whose contents match shell pattern
294 ''pattern''. The metacharacters do not treat `/' or `.'
295 specially.
296
297
298 -mmin ''n''
299
300
301 File's data was last modified ''n'' minutes
302 ago.
303
304
305 -mtime ''n''
306
307
308 File's data was last modified ''n''*24 hours
309 ago.
310
311
312 -name ''pattern''
313
314
315 Base of file name (the path with the leading directories
316 removed) matches shell pattern ''pattern''. The
317 metacharacters (`*', `?', and `[[]') do not match a `.' at
318 the start of the base name. To ignore a directory and the
319 files under it, use -prune; see an example in the
320 description of -path.
321
322
323 -newer ''file''
324
325
326 File was modified more recently than ''file''. -newer is
327 affected by -follow only if -follow comes before -newer on
328 the command line.
329
330
331 -nouser
332
333
334 No user corresponds to file's numeric user ID.
335
336
337 -nogroup
338
339
340 No group corresponds to file's numeric group
341 ID.
342
343
344 -path ''pattern''
345
346
347 File name matches shell pattern ''pattern''. The
348 metacharacters do not treat `/' or `.' specially; so, for
349 example,
350
351
352 find . -path './sr*sc'
353
354
355 will print an entry for a directory called './src/misc' (if
356 one exists). To ignore a whole directory tree, use -prune
357 rather than checking every file in the tree. For example, to
358 skip the directory `src/emacs' and all files and directories
359 under it, and print the names of the other files found, do
360 something like this:
361
362
363 find . -path './src/emacs' -prune -o -print
364
365
366 -perm ''mode''
367
368
369 File's permission bits are exactly ''mode'' (octal or
370 symbolic). Symbolic modes use mode 0 as a point of
371 departure.
372
373
374 -perm -''mode''
375
376
377 All of the permission bits ''mode'' are set for the
378 file.
379
380
381 -perm +''mode''
382
383
384 Any of the permission bits ''mode'' are set for the
385 file.
386
387
388 -regex ''pattern''
389
390
391 File name matches regular expression ''pattern''. This is
392 a match on the whole path, not a search. For example, to
393 match a file named `./fubar3', you can use the regular
394 expression `.*bar.' or `.*b.*3', but not
395 `b.*r3'.
396
397
398 -size ''n''[[bckw]
399
400
401 File uses ''n'' units of space. The units are 512-byte
402 blocks by default or if `b' follows ''n'', bytes if `c'
403 follows ''n'', kilobytes if `k' follows ''n'', or
404 2-byte words if `w' follows ''n''. The size does not
405 count indirect blocks, but it does count blocks in sparse
406 files that are not actually allocated.
407
408
409 -true
410
411
412 Always true.
413
414
415 -type ''c''
416
417
418 File is of type ''c'':
419
420
421 b
422
423
424 block (buffered) special
425
426
427 c
428
429
430 character (unbuffered) special
431
432
433 d
434
435
436 directory
437
438
439 p
440
441
442 named pipe (FIFO)
443
444
445 f
446
447
448 regular file
449
450
451 l
452
453
454 symbolic link
455
456
457 s
458
459
460 socket
461
462
463 D
464
465
466 door (Solaris)
467
468
469 -uid ''n''
470
471
472 File's numeric user ID is ''n''.
473
474
475 -used ''n''
476
477
478 File was last accessed ''n'' days after its status was
479 last changed.
480
481
482 -user ''uname''
483
484
485 File is owned by user ''uname'' (numeric user ID
486 allowed).
487
488
489 -xtype ''c''
490
491
492 The same as -type unless the file is a symbolic link. For
493 symbolic links: if -follow has not been given, true if the
494 file is a link to a file of type ''c''; if -follow has
495 been given, true if ''c'' is `l'. In other words, for
496 symbolic links, -xtype checks the type of the file that
497 -type does not check.
498
499
500 __ACTIONS__
501
502
503 -exec ''command'' ;
504
505
506 Execute ''command''; true if 0 status is returned. All
507 following arguments to __find__ are taken to be arguments
508 to the command until an argument consisting of `;' is
509 encountered. The string `{}' is replaced by the current file
510 name being processed everywhere it occurs in the arguments
511 to the command, not just in arguments where it is alone, as
512 in some versions of __find__. Both of these constructions
513 might need to be escaped (with a `') or quoted to protect
514 them from expansion by the shell. The command is executed in
515 the starting directory.
516
517
518 -fls ''file''
519
520
521 True; like -ls but write to ''file'' like
522 -fprint.
523
524
525 -fprint ''file''
526
527
528 True; print the full file name into file ''file''. If
529 ''file'' does not exist when __find__ is run, it is
530 created; if it does exist, it is truncated. The file names
531 ``/dev/stdout'' and ``/dev/stderr'' are handled specially;
532 they refer to the standard output and standard error output,
533 respectively.
534
535
536 -fprint0 ''file''
537
538
539 True; like -print0 but write to ''file'' like
540 -fprint.
541
542
543 -fprintf ''file format''
544
545
546 True; like -printf but write to ''file'' like
547 -fprint.
548
549
550 -ok ''command'' ;
551
552
553 Like -exec but ask the user first (on the standard input);
554 if the response does not start with `y' or `Y', do not run
555 the command, and return false.
556
557
558 -print
559
560
561 True; print the full file name on the standard output,
562 followed by a newline.
563
564
565 -print0
566
567
568 True; print the full file name on the standard output,
569 followed by a null character. This allows file names that
570 contain newlines to be correctly interpreted by programs
571 that process the __find__ output.
572
573
574 -printf ''format''
575
576
577 True; print ''format'' on the standard output,
578 interpreting `' escapes and `%' directives. Field widths and
579 precisions can be specified as with the `printf' C function.
580 Unlike -print, -printf does not add a newline at the end of
581 the string. The escapes and directives are:
582
583
584 a
585
586
587 Alarm bell.
588
589
590 b
591
592
593 Backspace.
594
595
596 c
597
598
599 Stop printing from this format immediately and flush the
600 output.
601
602
603 f
604
605
606 Form feed.
607
608
609 n
610
611
612 Newline.
613
614
615 r
616
617
618 Carriage return.
619
620
621 t
622
623
624 Horizontal tab.
625
626
627 v
628
629
630 Vertical tab.
631
632
633 \
634
635
636 A literal backslash (`').
637
638
639 A `' character followed by any other character is treated as
640 an ordinary character, so they both are
641 printed.
642
643
644 %%
645
646
647 A literal percent sign.
648
649
650 %a
651
652
653 File's last access time in the format returned by the C
654 `ctime' function.
655
656
657 %A''k''
658
659
660 File's last access time in the format specified by ''k'',
661 which is either `@' or a directive for the C `strftime'
662 function. The possible values for ''k'' are listed below;
663 some of them might not be available on all systems, due to
664 differences in `strftime' between systems.
665
666
667 @
668
669
670 seconds since Jan. 1, 1970, 00:00 GMT.
671
672
673 Time fields:
674
675
676 H
677
678
679 hour (00..23)
680
681
682 I
683
684
685 hour (01..12)
686
687
688 k
689
690
691 hour ( 0..23)
692
693
694 l
695
696
697 hour ( 1..12)
698
699
700 M
701
702
703 minute (00..59)
704
705
706 p
707
708
709 locale's AM or PM
710
711
712 r
713
714
715 time, 12-hour (hh:mm:ss [[AP]M)
716
717
718 S
719
720
721 second (00..61)
722
723
724 T
725
726
727 time, 24-hour (hh:mm:ss)
728
729
730 X
731
732
733 locale's time representation (H:M:S)
734
735
736 Z
737
738
739 time zone (e.g., EDT), or nothing if no time zone is
740 determinable
741
742
743 Date fields:
744
745
746 a
747
748
749 locale's abbreviated weekday name (Sun..Sat)
750
751
752 A
753
754
755 locale's full weekday name, variable length
756 (Sunday..Saturday)
757
758
759 b
760
761
762 locale's abbreviated month name (Jan..Dec)
763
764
765 B
766
767
768 locale's full month name, variable length
769 (January..December)
770
771
772 c
773
774
775 locale's date and time (Sat Nov 04 12:02:33 EST
776 1989)
777
778
779 d
780
781
782 day of month (01..31)
783
784
785 D
786
787
788 date (mm/dd/yy)
789
790
791 h
792
793
794 same as b
795
796
797 j
798
799
800 day of year (001..366)
801
802
803 m
804
805
806 month (01..12)
807
808
809 U
810
811
812 week number of year with Sunday as first day of week
813 (00..53)
814
815
816 w
817
818
819 day of week (0..6)
820
821
822 W
823
824
825 week number of year with Monday as first day of week
826 (00..53)
827
828
829 x
830
831
832 locale's date representation (mm/dd/yy)
833
834
835 y
836
837
838 last two digits of year (00..99)
839
840
841 Y
842
843
844 year (1970...)
845
846
847 %b
848
849
850 File's size in 512-byte blocks (rounded up).
851
852
853 %c
854
855
856 File's last status change time in the format returned by the
857 C `ctime' function.
858
859
860 %C''k''
861
862
863 File's last status change time in the format specified by
864 ''k'', which is the same as for %A.
865
866
867 %d
868
869
870 File's depth in the directory tree; 0 means the file is a
871 command line argument.
872
873
874 %f
875
876
877 File's name with any leading directories removed (only the
878 last element).
879
880
881 %F
882
883
884 Type of the filesystem the file is on; this value can be
885 used for -fstype.
886
887
888 %g
889
890
891 File's group name, or numeric group ID if the group has no
892 name.
893
894
895 %G
896
897
898 File's numeric group ID.
899
900
901 %h
902
903
904 Leading directories of file's name (all but the last
905 element).
906
907
908 %H
909
910
911 Command line argument under which file was
912 found.
913
914
915 %i
916
917
918 File's inode number (in decimal).
919
920
921 %k
922
923
924 File's size in 1K blocks (rounded up).
925
926
927 %l
928
929
930 Object of symbolic link (empty string if file is not a
931 symbolic link).
932
933
934 %m
935
936
937 File's permission bits (in octal).
938
939
940 %n
941
942
943 Number of hard links to file.
944
945
946 %p
947
948
949 File's name.
950
951
952 %P
953
954
955 File's name with the name of the command line argument under
956 which it was found removed.
957
958
959 %s
960
961
962 File's size in bytes.
963
964
965 %t
966
967
968 File's last modification time in the format returned by the
969 C `ctime' function.
970
971
972 %T''k''
973
974
975 File's last modification time in the format specified by
976 ''k'', which is the same as for %A.
977
978
979 %u
980
981
982 File's user name, or numeric user ID if the user has no
983 name.
984
985
986 %U
987
988
989 File's numeric user ID.
990
991
992 A `%' character followed by any other character is discarded
993 (but the other character is printed).
994
995
996 -prune
997
998
999 If -depth is not given, true; do not descend the current
1000 directory.
1001 If -depth is given, false; no effect.
1002
1003
1004 -ls
1005
1006
1007 True; list current file in `ls -dils' format on standard
1008 output. The block counts are of 1K blocks, unless the
1009 environment variable POSIXLY_CORRECT is set, in which case
1010 512-byte blocks are used.
1011
1012
1013 __OPERATORS__
1014
1015
1016 Listed in order of decreasing precedence:
1017
1018
1019 ( ''expr'' )
1020
1021
1022 Force precedence.
1023
1024
1025 ! ''expr''
1026
1027
1028 True if ''expr'' is false.
1029
1030
1031 -not ''expr''
1032
1033
1034 Same as ! ''expr''.
1035
1036
1037 ''expr1 expr2''
1038
1039
1040 And (implied); ''expr2'' is not evaluated if ''expr1''
1041 is false.
1042
1043
1044 ''expr1'' -a ''expr2''
1045
1046
1047 Same as ''expr1 expr2''.
1048
1049
1050 ''expr1'' -and ''expr2''
1051
1052
1053 Same as ''expr1 expr2''.
1054
1055
1056 ''expr1'' -o ''expr2''
1057
1058
1059 Or; ''expr2'' is not evaluated if ''expr1'' is
1060 true.
1061
1062
1063 ''expr1'' -or ''expr2''
1064
1065
1066 Same as ''expr1'' -o ''expr2''.
1067
1068
1069 ''expr1'' , ''expr2''
1070
1071
1072 List; both ''expr1'' and ''expr2'' are always
1073 evaluated. The value of ''expr1'' is discarded; the value
1074 of the list is the value of ''expr2''.
1075 !!SEE ALSO
1076
1077
1078 __locate__(1L), __locatedb__(5L), __updatedb__(1L),
1079 __xargs__(1L) __Finding Files__ (on-line in Info, or
1080 printed)
1081 ----
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.