1FIND(1)                     General Commands Manual                    FIND(1)
2
3
4

NAME

6       find - search for files in a directory hierarchy
7

SYNOPSIS

9       find  [-H]  [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [ex‐
10       pression]
11

DESCRIPTION

13       This manual page documents the GNU version of find.  GNU find  searches
14       the  directory  tree  rooted at each given starting-point by evaluating
15       the given expression from left to right,  according  to  the  rules  of
16       precedence  (see  section  OPERATORS),  until the outcome is known (the
17       left hand side is false for and operations,  true  for  or),  at  which
18       point  find  moves  on  to the next file name.  If no starting-point is
19       specified, `.' is assumed.
20
21       If you are using find in an environment  where  security  is  important
22       (for  example  if  you  are  using  it  to  search directories that are
23       writable by other users), you should read the `Security Considerations'
24       chapter  of  the findutils documentation, which is called Finding Files
25       and comes with findutils.  That document also includes a lot  more  de‐
26       tail  and  discussion  than this manual page, so you may find it a more
27       useful source of information.
28

OPTIONS

30       The -H, -L and -P options control  the  treatment  of  symbolic  links.
31       Command-line  arguments  following these are taken to be names of files
32       or directories to be examined, up to the  first  argument  that  begins
33       with  `-', or the argument `(' or `!'.  That argument and any following
34       arguments are taken to be the  expression  describing  what  is  to  be
35       searched  for.   If  no paths are given, the current directory is used.
36       If no expression is given, the  expression  -print  is  used  (but  you
37       should probably consider using -print0 instead, anyway).
38
39       This  manual  page  talks  about  `options' within the expression list.
40       These options control the behaviour of find but are  specified  immedi‐
41       ately after the last path name.  The five `real' options -H, -L, -P, -D
42       and -O must appear before the first path name, if  at  all.   A  double
43       dash  -- could theoretically be used to signal that any remaining argu‐
44       ments are not options, but this does not really work  due  to  the  way
45       find  determines  the end of the following path arguments: it does that
46       by reading until an expression argument comes (which also starts with a
47       `-').   Now, if a path argument would start with a `-', then find would
48       treat it as expression argument instead.   Thus,  to  ensure  that  all
49       start points are taken as such, and especially to prevent that wildcard
50       patterns expanded by the calling shell are not  mistakenly  treated  as
51       expression  arguments, it is generally safer to prefix wildcards or du‐
52       bious path names with either `./' or to use absolute path names  start‐
53       ing with '/'.
54
55       -P     Never  follow  symbolic  links.   This is the default behaviour.
56              When find examines or prints information about  files,  and  the
57              file  is  a  symbolic  link, the information used shall be taken
58              from the properties of the symbolic link itself.
59
60
61       -L     Follow symbolic links.  When find examines or prints information
62              about  files, the information used shall be taken from the prop‐
63              erties of the file to which the link points, not from  the  link
64              itself (unless it is a broken symbolic link or find is unable to
65              examine the file to which the link points).  Use of this  option
66              implies  -noleaf.   If you later use the -P option, -noleaf will
67              still be in effect.  If -L is in effect  and  find  discovers  a
68              symbolic link to a subdirectory during its search, the subdirec‐
69              tory pointed to by the symbolic link will be searched.
70
71              When the -L option is in effect, the -type predicate will always
72              match  against  the type of the file that a symbolic link points
73              to rather than the link itself (unless the symbolic link is bro‐
74              ken).   Actions  that  can cause symbolic links to become broken
75              while find is executing (for example -delete) can give  rise  to
76              confusing  behaviour.   Using  -L  causes the -lname and -ilname
77              predicates always to return false.
78
79
80       -H     Do not follow symbolic links, except while processing  the  com‐
81              mand  line  arguments.  When find examines or prints information
82              about files, the information used shall be taken from the  prop‐
83              erties  of the symbolic link itself.  The only exception to this
84              behaviour is when a file specified on the command line is a sym‐
85              bolic  link,  and the link can be resolved.  For that situation,
86              the information used is taken from whatever the link  points  to
87              (that is, the link is followed).  The information about the link
88              itself is used as a fallback if the file pointed to by the  sym‐
89              bolic  link  cannot  be examined.  If -H is in effect and one of
90              the paths specified on the command line is a symbolic link to  a
91              directory,  the  contents  of  that  directory  will be examined
92              (though of course -maxdepth 0 would prevent this).
93
94       If more than one of -H, -L and -P is specified, each overrides the oth‐
95       ers; the last one appearing on the command line takes effect.  Since it
96       is the default, the -P option should be considered to be in effect  un‐
97       less either -H or -L is specified.
98
99       GNU  find  frequently  stats files during the processing of the command
100       line itself, before any searching has begun.  These options also affect
101       how those arguments are processed.  Specifically, there are a number of
102       tests that compare files listed on the command line against a  file  we
103       are  currently  considering.   In  each case, the file specified on the
104       command line will have been examined and some of  its  properties  will
105       have been saved.  If the named file is in fact a symbolic link, and the
106       -P option is in effect (or if neither -H nor -L  were  specified),  the
107       information  used  for the comparison will be taken from the properties
108       of the symbolic link.  Otherwise, it will be taken from the  properties
109       of  the  file  the link points to.  If find cannot follow the link (for
110       example because it has insufficient privileges or the link points to  a
111       nonexistent file) the properties of the link itself will be used.
112
113       When  the  -H or -L options are in effect, any symbolic links listed as
114       the argument of -newer will be dereferenced, and the timestamp will  be
115       taken  from  the file to which the symbolic link points.  The same con‐
116       sideration applies to -newerXY, -anewer and -cnewer.
117
118       The -follow option has a similar effect to -L, though it  takes  effect
119       at  the  point where it appears (that is, if -L is not used but -follow
120       is, any symbolic links appearing after -follow on the command line will
121       be dereferenced, and those before it will not).
122
123
124       -D debugopts
125              Print  diagnostic  information;  this can be helpful to diagnose
126              problems with why find is not doing what you want.  The list  of
127              debug  options  should be comma separated.  Compatibility of the
128              debug options is not guaranteed between releases  of  findutils.
129              For  a  complete  list of valid debug options, see the output of
130              find -D help.  Valid debug options include
131
132              exec   Show diagnostic information relating to -exec,  -execdir,
133                     -ok and -okdir
134
135              opt    Prints  diagnostic  information relating to the optimisa‐
136                     tion of the expression tree; see the -O option.
137
138              rates  Prints a summary indicating how often each predicate suc‐
139                     ceeded or failed.
140
141              search Navigate the directory tree verbosely.
142
143              stat   Print  messages  as  files are examined with the stat and
144                     lstat system calls.  The find program tries  to  minimise
145                     such calls.
146
147              tree   Show  the  expression  tree in its original and optimised
148                     form.
149
150              all    Enable all of the other debug options (but help).
151
152              help   Explain the debugging options.
153
154       -Olevel
155              Enables query optimisation.  The find program reorders tests  to
156              speed up execution while preserving the overall effect; that is,
157              predicates with side effects are not reordered relative to  each
158              other.   The  optimisations performed at each optimisation level
159              are as follows.
160
161              0      Equivalent to optimisation level 1.
162
163              1      This is the default optimisation level and corresponds to
164                     the  traditional behaviour.  Expressions are reordered so
165                     that tests based only on the names of files (for  example
166                     -name and -regex) are performed first.
167
168              2      Any  -type  or -xtype tests are performed after any tests
169                     based only on the names of files, but  before  any  tests
170                     that  require information from the inode.  On many modern
171                     versions of Unix, file types are  returned  by  readdir()
172                     and so these predicates are faster to evaluate than pred‐
173                     icates which need to stat the file first.  If you use the
174                     -fstype FOO  predicate  and specify a filesystem type FOO
175                     which is not known (that is, present in  `/etc/mtab')  at
176                     the  time  find  starts,  that predicate is equivalent to
177                     -false.
178
179              3      At this optimisation level, the full cost-based query op‐
180                     timiser  is  enabled.   The order of tests is modified so
181                     that cheap (i.e. fast) tests are performed first and more
182                     expensive ones are performed later, if necessary.  Within
183                     each cost band, predicates are evaluated earlier or later
184                     according  to  whether they are likely to succeed or not.
185                     For -o, predicates which are likely to succeed are evalu‐
186                     ated  earlier, and for -a, predicates which are likely to
187                     fail are evaluated earlier.
188
189              The cost-based optimiser has a fixed  idea  of  how  likely  any
190              given  test  is to succeed.  In some cases the probability takes
191              account of the specific nature of the test (for example, -type f
192              is  assumed  to  be  more  likely to succeed than -type c).  The
193              cost-based optimiser is currently being evaluated.  If  it  does
194              not actually improve the performance of find, it will be removed
195              again.  Conversely, optimisations that prove to be reliable, ro‐
196              bust  and  effective may be enabled at lower optimisation levels
197              over time.  However, the default  behaviour  (i.e.  optimisation
198              level  1)  will not be changed in the 4.3.x release series.  The
199              findutils test suite runs all the tests on find at each  optimi‐
200              sation level and ensures that the result is the same.
201

EXPRESSION

203       The  part  of the command line after the list of starting points is the
204       expression.  This is a kind of query specification  describing  how  we
205       match  files  and  what we do with the files that were matched.  An ex‐
206       pression is composed of a sequence of things:
207
208
209       Tests  Tests return a true or false value, usually on the basis of some
210              property  of a file we are considering.  The -empty test for ex‐
211              ample is true only when the current file is empty.
212
213
214       Actions
215              Actions have side effects (such as  printing  something  on  the
216              standard  output) and return either true or false, usually based
217              on whether or not they are successful.  The  -print  action  for
218              example prints the name of the current file on the standard out‐
219              put.
220
221
222       Global options
223              Global options affect the operation of tests and actions  speci‐
224              fied on any part of the command line.  Global options always re‐
225              turn true.  The -depth option for example  makes  find  traverse
226              the file system in a depth-first order.
227
228
229       Positional options
230              Positional  options  affect  only  tests or actions which follow
231              them.  Positional options always return  true.   The  -regextype
232              option for example is positional, specifying the regular expres‐
233              sion dialect for regular expressions occurring later on the com‐
234              mand line.
235
236
237       Operators
238              Operators  join  together the other items within the expression.
239              They include for example -o (meaning logical OR) and -a (meaning
240              logical AND).  Where an operator is missing, -a is assumed.
241
242
243       The -print action is performed on all files for which the whole expres‐
244       sion is true, unless it contains an action other than -prune or  -quit.
245       Actions  which inhibit the default -print are -delete, -exec, -execdir,
246       -ok, -okdir, -fls, -fprint, -fprintf, -ls, -print and -printf.
247
248
249       The -delete action also acts like an option (since it implies -depth).
250
251
252   POSITIONAL OPTIONS
253       Positional options always return true.  They affect only  tests  occur‐
254       ring later on the command line.
255
256
257       -daystart
258              Measure  times  (for  -amin,  -atime,  -cmin, -ctime, -mmin, and
259              -mtime) from the beginning of today rather than  from  24  hours
260              ago.   This  option only affects tests which appear later on the
261              command line.
262
263
264       -follow
265              Deprecated; use the -L  option  instead.   Dereference  symbolic
266              links.   Implies -noleaf.  The -follow option affects only those
267              tests which appear after it on the command line.  Unless the  -H
268              or -L option has been specified, the position of the -follow op‐
269              tion changes the behaviour of the -newer  predicate;  any  files
270              listed  as  the  argument of -newer will be dereferenced if they
271              are symbolic links.  The same consideration applies to -newerXY,
272              -anewer and -cnewer.  Similarly, the -type predicate will always
273              match against the type of the file that a symbolic  link  points
274              to rather than the link itself.  Using -follow causes the -lname
275              and -ilname predicates always to return false.
276
277
278       -regextype type
279              Changes the regular expression syntax understood by  -regex  and
280              -iregex  tests  which  occur  later on the command line.  To see
281              which regular expression types are known,  use  -regextype help.
282              The Texinfo documentation (see SEE ALSO) explains the meaning of
283              and differences between the various types of regular expression.
284
285
286       -warn, -nowarn
287              Turn warning messages on or off.  These warnings apply  only  to
288              the  command  line  usage, not to any conditions that find might
289              encounter when it searches directories.  The  default  behaviour
290              corresponds  to -warn if standard input is a tty, and to -nowarn
291              otherwise.  If a warning message relating to command-line  usage
292              is  produced,  the  exit status of find is not affected.  If the
293              POSIXLY_CORRECT environment variable is set, and -warn  is  also
294              used,  it  is  not specified which, if any, warnings will be ac‐
295              tive.
296
297
298   GLOBAL OPTIONS
299       Global options always return true.  Global options take effect even for
300       tests  which  occur earlier on the command line.  To prevent confusion,
301       global options should specified on the command-line after the  list  of
302       start  points, just before the first test, positional option or action.
303       If you specify a global option in some other place, find will  issue  a
304       warning message explaining that this can be confusing.
305
306       The global options occur after the list of start points, and so are not
307       the same kind of option as -L, for example.
308
309
310       -d     A synonym for -depth, for compatibility  with  FreeBSD,  NetBSD,
311              MacOS X and OpenBSD.
312
313
314       -depth Process  each  directory's contents before the directory itself.
315              The -delete action also implies -depth.
316
317
318       -help, --help
319              Print a summary of the command-line usage of find and exit.
320
321
322       -ignore_readdir_race
323              Normally, find will emit an error message when it fails to  stat
324              a  file.   If you give this option and a file is deleted between
325              the time find reads the name of the file from the directory  and
326              the time it tries to stat the file, no error message will be is‐
327              sued.  This also applies to files or directories whose names are
328              given on the command line.  This option takes effect at the time
329              the command line is read, which means that you cannot search one
330              part  of  the filesystem with this option on and part of it with
331              this option off (if you need to do that, you will need to  issue
332              two  find  commands instead, one with the option and one without
333              it).
334
335              Furthermore, find with the -ignore_readdir_race option will  ig‐
336              nore  errors of the -delete action in the case the file has dis‐
337              appeared since the parent directory was read: it will not output
338              an  error  diagnostic, and the return code of the -delete action
339              will be true.
340
341
342       -maxdepth levels
343              Descend at most levels (a non-negative integer) levels of direc‐
344              tories  below the starting-points.  Using -maxdepth 0 means only
345              apply the tests and actions to the starting-points themselves.
346
347
348       -mindepth levels
349              Do not apply any tests or actions at levels less than levels  (a
350              non-negative  integer).   Using  -mindepth 1  means  process all
351              files except the starting-points.
352
353
354       -mount Don't descend directories on other  filesystems.   An  alternate
355              name  for  -xdev,  for compatibility with some other versions of
356              find.
357
358
359       -noignore_readdir_race
360              Turns off the effect of -ignore_readdir_race.
361
362
363       -noleaf
364              Do not optimize by assuming that  directories  contain  2  fewer
365              subdirectories  than  their  hard  link  count.   This option is
366              needed when searching filesystems that do not  follow  the  Unix
367              directory-link  convention, such as CD-ROM or MS-DOS filesystems
368              or AFS volume mount points.  Each directory  on  a  normal  Unix
369              filesystem  has  at least 2 hard links: its name and its `.' en‐
370              try.  Additionally, its subdirectories (if any) each have a `..'
371              entry linked to that directory.  When find is examining a direc‐
372              tory, after it has statted 2 fewer subdirectories than  the  di‐
373              rectory's  link  count, it knows that the rest of the entries in
374              the directory are non-directories (`leaf' files in the directory
375              tree).   If  only the files' names need to be examined, there is
376              no need to stat them;  this  gives  a  significant  increase  in
377              search speed.
378
379
380       -version, --version
381              Print the find version number and exit.
382
383
384       -xautofs
385              Don't descend directories on autofs filesystems.
386
387
388       -xdev  Don't descend directories on other filesystems.
389
390
391   TESTS
392       Some  tests,  for  example -newerXY and -samefile, allow comparison be‐
393       tween the file currently being examined and some reference file  speci‐
394       fied  on  the command line.  When these tests are used, the interpreta‐
395       tion of the reference file is determined by the options -H, -L  and  -P
396       and any previous -follow, but the reference file is only examined once,
397       at the time the command line is parsed.  If the reference  file  cannot
398       be examined (for example, the stat(2) system call fails for it), an er‐
399       ror message is issued, and find exits with a nonzero status.
400
401       A numeric argument n can be specified to  tests  (like  -amin,  -mtime,
402       -gid, -inum, -links, -size, -uid and -used) as
403
404       +n     for greater than n,
405
406       -n     for less than n,
407
408       n      for exactly n.
409
410       Supported tests:
411
412
413       -amin n
414              File was last accessed less than, more than or exactly n minutes
415              ago.
416
417
418       -anewer reference
419              Time of the last access of the current file is more recent  than
420              that  of  the  last data modification of the reference file.  If
421              reference is a symbolic link and the -H option or the -L  option
422              is in effect, then the time of the last data modification of the
423              file it points to is always used.
424
425
426       -atime n
427              File was last accessed less than,  more  than  or  exactly  n*24
428              hours  ago.   When find figures out how many 24-hour periods ago
429              the file was last accessed, any fractional part is  ignored,  so
430              to  match  -atime +1,  a file has to have been accessed at least
431              two days ago.
432
433
434       -cmin n
435              File's status was last changed less than, more than or exactly n
436              minutes ago.
437
438
439       -cnewer reference
440              Time  of  the last status change of the current file is more re‐
441              cent than that of the last data modification  of  the  reference
442              file.   If reference is a symbolic link and the -H option or the
443              -L option is in effect, then the time of the last data modifica‐
444              tion of the file it points to is always used.
445
446
447       -ctime n
448              File's  status  was last changed less than, more than or exactly
449              n*24 hours ago.  See the comments for -atime to  understand  how
450              rounding affects the interpretation of file status change times.
451
452
453       -empty File is empty and is either a regular file or a directory.
454
455
456       -executable
457              Matches  files  which  are  executable and directories which are
458              searchable (in a file name  resolution  sense)  by  the  current
459              user.   This  takes  into account access control lists and other
460              permissions artefacts which the -perm test ignores.   This  test
461              makes  use of the access(2) system call, and so can be fooled by
462              NFS servers which do UID mapping (or root-squashing), since many
463              systems implement access(2) in the client's kernel and so cannot
464              make use of the UID mapping information held on the server.  Be‐
465              cause  this  test  is  based only on the result of the access(2)
466              system call, there is no guarantee that a file  for  which  this
467              test succeeds can actually be executed.
468
469
470       -false Always false.
471
472
473       -fstype type
474              File  is  on  a  filesystem  of type type.  The valid filesystem
475              types vary among different versions of Unix; an incomplete  list
476              of filesystem types that are accepted on some version of Unix or
477              another is: ufs, 4.2, 4.3, nfs, tmp, mfs, S51K, S52K.   You  can
478              use  -printf  with  the  %F  directive  to see the types of your
479              filesystems.
480
481
482       -gid n File's numeric group ID is less than, more than or exactly n.
483
484
485       -group gname
486              File belongs to group gname (numeric group ID allowed).
487
488
489       -ilname pattern
490              Like -lname, but the match is case insensitive.  If the  -L  op‐
491              tion or the -follow option is in effect, this test returns false
492              unless the symbolic link is broken.
493
494
495
496       -iname pattern
497              Like -name, but the match is case insensitive.  For example, the
498              patterns  `fo*'  and  `F??'  match  the file names `Foo', `FOO',
499              `foo', `fOo', etc.  The pattern `*foo*` will also match  a  file
500              called '.foobar'.
501
502
503       -inum n
504              File  has  inode number smaller than, greater than or exactly n.
505              It is normally easier to use the -samefile test instead.
506
507
508       -ipath pattern
509              Like -path.  but the match is case insensitive.
510
511
512       -iregex pattern
513              Like -regex, but the match is case insensitive.
514
515
516       -iwholename pattern
517              See -ipath.  This alternative is less portable than -ipath.
518
519
520       -links n
521              File has less than, more than or exactly n hard links.
522
523
524       -lname pattern
525              File is a symbolic link whose contents match shell pattern  pat‐
526              tern.  The metacharacters do not treat `/' or `.' specially.  If
527              the -L option or the -follow option is in effect, this test  re‐
528              turns false unless the symbolic link is broken.
529
530
531       -mmin n
532              File's  data was last modified less than, more than or exactly n
533              minutes ago.
534
535
536       -mtime n
537              File's data was last modified less than, more  than  or  exactly
538              n*24  hours  ago.  See the comments for -atime to understand how
539              rounding affects the interpretation of file modification times.
540
541
542       -name pattern
543              Base of file name (the path with  the  leading  directories  re‐
544              moved)  matches  shell pattern pattern.  Because the leading di‐
545              rectories are removed, the file names  considered  for  a  match
546              with -name will never include a slash, so `-name a/b' will never
547              match anything (you probably need  to  use  -path  instead).   A
548              warning  is issued if you try to do this, unless the environment
549              variable POSIXLY_CORRECT is set.  The metacharacters (`*',  `?',
550              and  `[]')  match a `.' at the start of the base name (this is a
551              change in findutils-4.2.2; see section STANDARDS CONFORMANCE be‐
552              low).   To ignore a directory and the files under it, use -prune
553              rather than checking every file in the tree; see an  example  in
554              the  description  of  that action.  Braces are not recognised as
555              being special, despite the fact that some shells including  Bash
556              imbue  braces  with  a  special  meaning in shell patterns.  The
557              filename matching is performed with the use  of  the  fnmatch(3)
558              library function.  Don't forget to enclose the pattern in quotes
559              in order to protect it from expansion by the shell.
560
561
562       -newer reference
563              Time of the last data modification of the current file  is  more
564              recent  than that of the last data modification of the reference
565              file.  If reference is a symbolic link and the -H option or  the
566              -L option is in effect, then the time of the last data modifica‐
567              tion of the file it points to is always used.
568
569
570       -newerXY reference
571              Succeeds if timestamp X of the file being  considered  is  newer
572              than timestamp Y of the file reference.  The letters X and Y can
573              be any of the following letters:
574
575
576              a   The access time of the file reference
577              B   The birth time of the file reference
578              c   The inode status change time of reference
579              m   The modification time of the file reference
580              t   reference is interpreted directly as a time
581
582              Some combinations are invalid; for example, it is invalid for  X
583              to  be t.  Some combinations are not implemented on all systems;
584              for example B is not supported on all systems.  If an invalid or
585              unsupported  combination  of  XY is specified, a fatal error re‐
586              sults.  Time specifications are interpreted as for the  argument
587              to  the -d option of GNU date.  If you try to use the birth time
588              of a reference file, and the birth time cannot be determined,  a
589              fatal error message results.  If you specify a test which refers
590              to the birth time of files being examined, this test  will  fail
591              for any files where the birth time is unknown.
592
593
594       -nogroup
595              No group corresponds to file's numeric group ID.
596
597
598       -nouser
599              No user corresponds to file's numeric user ID.
600
601
602       -path pattern
603              File  name matches shell pattern pattern.  The metacharacters do
604              not treat `/' or `.' specially; so, for example,
605                  find . -path "./sr*sc"
606              will print an entry for a directory called  ./src/misc  (if  one
607              exists).   To  ignore  a whole directory tree, use -prune rather
608              than checking every file in the tree.   Note  that  the  pattern
609              match  test applies to the whole file name, starting from one of
610              the start points named on the command line.  It would only  make
611              sense  to  use  an absolute path name here if the relevant start
612              point is also an absolute path.  This means  that  this  command
613              will never match anything:
614                  find bar -path /foo/bar/myfile -print
615              Find compares the -path argument with the concatenation of a di‐
616              rectory name and the base  name  of  the  file  it's  examining.
617              Since the concatenation will never end with a slash, -path argu‐
618              ments ending in a slash will match  nothing  (except  perhaps  a
619              start point specified on the command line).  The predicate -path
620              is also supported by HP-UX find and is part of  the  POSIX  2008
621              standard.
622
623
624       -perm mode
625              File's  permission  bits  are  exactly mode (octal or symbolic).
626              Since an exact match is required, if you want to use  this  form
627              for  symbolic  modes,  you  may have to specify a rather complex
628              mode string.  For example `-perm  g=w'  will  only  match  files
629              which  have  mode 0020 (that is, ones for which group write per‐
630              mission is the only permission set).  It is more likely that you
631              will want to use the `/' or `-' forms, for example `-perm -g=w',
632              which matches any file with group write permission.  See the EX‐
633              AMPLES section for some illustrative examples.
634
635
636       -perm -mode
637              All  of the permission bits mode are set for the file.  Symbolic
638              modes are accepted in this form, and this is usually the way  in
639              which  you would want to use them.  You must specify `u', `g' or
640              `o' if you use a symbolic mode.  See the  EXAMPLES  section  for
641              some illustrative examples.
642
643
644       -perm /mode
645              Any  of the permission bits mode are set for the file.  Symbolic
646              modes are accepted in this form.  You must specify `u',  `g'  or
647              `o'  if  you  use a symbolic mode.  See the EXAMPLES section for
648              some illustrative examples.  If no permission bits in  mode  are
649              set,  this test matches any file (the idea here is to be consis‐
650              tent with the behaviour of -perm -000).
651
652
653       -perm +mode
654              This is no longer  supported  (and  has  been  deprecated  since
655              2005).  Use -perm /mode instead.
656
657
658       -readable
659              Matches  files  which  are  readable  by the current user.  This
660              takes into account access control lists  and  other  permissions
661              artefacts  which the -perm test ignores.  This test makes use of
662              the access(2) system call, and so can be fooled by  NFS  servers
663              which do UID mapping (or root-squashing), since many systems im‐
664              plement access(2) in the client's kernel and so cannot make  use
665              of the UID mapping information held on the server.
666
667
668       -regex pattern
669              File  name  matches regular expression pattern.  This is a match
670              on the whole path, not a search.  For example, to match  a  file
671              named  ./fubar3,  you can use the regular expression `.*bar.' or
672              `.*b.*3', but not `f.*r3'.  The regular  expressions  understood
673              by  find  are  by default Emacs Regular Expressions (except that
674              `.' matches newline), but this can be changed with  the  -regex‐
675              type option.
676
677
678       -samefile name
679              File  refers  to  the same inode as name.  When -L is in effect,
680              this can include symbolic links.
681
682
683       -size n[cwbkMG]
684              File uses less than, more than or  exactly  n  units  of  space,
685              rounding up.  The following suffixes can be used:
686
687              `b'    for  512-byte blocks (this is the default if no suffix is
688                     used)
689
690              `c'    for bytes
691
692              `w'    for two-byte words
693
694              `k'    for kibibytes (KiB, units of 1024 bytes)
695
696              `M'    for mebibytes (MiB, units of 1024 * 1024 = 1048576 bytes)
697
698              `G'    for gibibytes (GiB,  units  of  1024  *  1024  *  1024  =
699                     1073741824 bytes)
700
701              The  size  is simply the st_size member of the struct stat popu‐
702              lated by the lstat (or stat) system call, rounded  up  as  shown
703              above.   In other words, it's consistent with the result you get
704              for ls -l.  Bear in mind that the `%k' and  `%b'  format  speci‐
705              fiers  of -printf handle sparse files differently.  The `b' suf‐
706              fix always denotes 512-byte blocks and never  1024-byte  blocks,
707              which is different to the behaviour of -ls.
708
709              The  +  and  -  prefixes  signify greater than and less than, as
710              usual; i.e., an exact size of n units does not match.   Bear  in
711              mind  that  the  size is rounded up to the next unit.  Therefore
712              -size -1M is not equivalent to -size -1048576c.  The former only
713              matches  empty  files,  the  latter  matches  files  from  0  to
714              1,048,575 bytes.
715
716       -true  Always true.
717
718
719       -type c
720              File is of type c:
721
722              b      block (buffered) special
723
724              c      character (unbuffered) special
725
726              d      directory
727
728              p      named pipe (FIFO)
729
730              f      regular file
731
732              l      symbolic link; this is never true if the -L option or the
733                     -follow  option is in effect, unless the symbolic link is
734                     broken.  If you want to search for symbolic links when -L
735                     is in effect, use -xtype.
736
737              s      socket
738
739              D      door (Solaris)
740
741              To  search  for  more  than one type at once, you can supply the
742              combined list of type letters separated by a comma `,' (GNU  ex‐
743              tension).
744
745       -uid n File's numeric user ID is less than, more than or exactly n.
746
747
748       -used n
749              File  was  last  accessed less than, more than or exactly n days
750              after its status was last changed.
751
752
753       -user uname
754              File is owned by user uname (numeric user ID allowed).
755
756
757       -wholename pattern
758              See -path.  This alternative is less portable than -path.
759
760
761       -writable
762              Matches files which are writable  by  the  current  user.   This
763              takes  into  account  access control lists and other permissions
764              artefacts which the -perm test ignores.  This test makes use  of
765              the  access(2)  system call, and so can be fooled by NFS servers
766              which do UID mapping (or root-squashing), since many systems im‐
767              plement  access(2) in the client's kernel and so cannot make use
768              of the UID mapping information held on the server.
769
770
771       -xtype c
772              The same as -type unless the file is a symbolic link.  For  sym‐
773              bolic  links:  if the -H or -P option was specified, true if the
774              file is a link to a file of type c; if the -L  option  has  been
775              given,  true  if  c is `l'.  In other words, for symbolic links,
776              -xtype checks the type of the file that -type does not check.
777
778       -context pattern
779              (SELinux only) Security context of the file  matches  glob  pat‐
780              tern.
781
782
783   ACTIONS
784       -delete
785              Delete files; true if removal succeeded.  If the removal failed,
786              an error message is issued.  If -delete fails, find's exit  sta‐
787              tus  will be nonzero (when it eventually exits).  Use of -delete
788              automatically turns on the `-depth' option.
789
790              Warnings: Don't forget that the find command line  is  evaluated
791              as an expression, so putting -delete first will make find try to
792              delete everything below the starting points you specified.  When
793              testing  a  find  command line that you later intend to use with
794              -delete, you should explicitly specify -depth in order to  avoid
795              later  surprises.   Because  -delete  implies -depth, you cannot
796              usefully use -prune and -delete together.
797
798              Together with the -ignore_readdir_race option, find will  ignore
799              errors  of  the  -delete  action in the case the file has disap‐
800              peared since the parent directory was read: it will  not  output
801              an  error  diagnostic, and the return code of the -delete action
802              will be true.
803
804
805       -exec command ;
806              Execute command; true if 0 status is  returned.   All  following
807              arguments to find are taken to be arguments to the command until
808              an argument consisting of `;' is encountered.  The  string  `{}'
809              is  replaced by the current file name being processed everywhere
810              it occurs in the arguments to the command, not just in arguments
811              where  it  is alone, as in some versions of find.  Both of these
812              constructions might need to be escaped (with a `\') or quoted to
813              protect them from expansion by the shell.  See the EXAMPLES sec‐
814              tion for examples of the use of the -exec option.  The specified
815              command  is run once for each matched file.  The command is exe‐
816              cuted in the starting directory.  There are unavoidable security
817              problems surrounding use of the -exec action; you should use the
818              -execdir option instead.
819
820
821       -exec command {} +
822              This variant of the -exec action runs the specified  command  on
823              the  selected  files, but the command line is built by appending
824              each selected file name at the end; the total number of  invoca‐
825              tions  of  the  command  will  be  much  less than the number of
826              matched files.  The command line is built in much the  same  way
827              that  xargs builds its command lines.  Only one instance of `{}'
828              is allowed within the command, and it must appear  at  the  end,
829              immediately  before the `+'; it needs to be escaped (with a `\')
830              or quoted to protect it from interpretation by the  shell.   The
831              command  is  executed in the starting directory.  If any invoca‐
832              tion with the `+' form returns a non-zero value as exit  status,
833              then find returns a non-zero exit status.  If find encounters an
834              error, this can sometimes cause an immediate exit, so some pend‐
835              ing  commands  may not be run at all.  For this reason -exec my-
836              command ... {} + -quit may not result in my-command actually be‐
837              ing run.  This variant of -exec always returns true.
838
839
840       -execdir command ;
841
842       -execdir command {} +
843              Like  -exec, but the specified command is run from the subdirec‐
844              tory containing the matched file, which is not normally the  di‐
845              rectory in which you started find.  As with -exec, the {} should
846              be quoted if find is being invoked from a shell.   This  a  much
847              more secure method for invoking commands, as it avoids race con‐
848              ditions during resolution of the paths to the matched files.  As
849              with  the  -exec  action,  the `+' form of -execdir will build a
850              command line to process more than  one  matched  file,  but  any
851              given  invocation  of command will only list files that exist in
852              the same subdirectory.  If you use this option, you must  ensure
853              that  your  $PATH  environment  variable does not reference `.';
854              otherwise, an attacker can run any commands they like by leaving
855              an appropriately-named file in a directory in which you will run
856              -execdir.  The same applies to having entries in $PATH which are
857              empty or which are not absolute directory names.  If any invoca‐
858              tion with the `+' form returns a non-zero value as exit  status,
859              then find returns a non-zero exit status.  If find encounters an
860              error, this can sometimes cause an immediate exit, so some pend‐
861              ing  commands  may  not be run at all.  The result of the action
862              depends on whether the + or the ; variant is  being  used;  -ex‐
863              ecdir command {} +  always  returns  true,  while  -execdir com‐
864              mand {} ; returns true only if command returns 0.
865
866
867
868       -fls file
869              True; like -ls but write to file like -fprint.  The output  file
870              is  always created, even if the predicate is never matched.  See
871              the UNUSUAL FILENAMES section for information about how  unusual
872              characters in filenames are handled.
873
874
875       -fprint file
876              True; print the full file name into file file.  If file does not
877              exist when find is run, it is created; if it does exist,  it  is
878              truncated.   The file names /dev/stdout and /dev/stderr are han‐
879              dled specially; they refer to the standard output  and  standard
880              error  output, respectively.  The output file is always created,
881              even if the predicate is never matched.  See the  UNUSUAL  FILE‐
882              NAMES  section  for  information about how unusual characters in
883              filenames are handled.
884
885
886       -fprint0 file
887              True; like -print0 but write to file like -fprint.   The  output
888              file  is always created, even if the predicate is never matched.
889              See the UNUSUAL FILENAMES section for information about how  un‐
890              usual characters in filenames are handled.
891
892
893       -fprintf file format
894              True;  like  -printf but write to file like -fprint.  The output
895              file is always created, even if the predicate is never  matched.
896              See  the UNUSUAL FILENAMES section for information about how un‐
897              usual characters in filenames are handled.
898
899
900       -ls    True; list current file in ls -dils format on  standard  output.
901              The  block  counts  are  of  1 KB blocks, unless the environment
902              variable POSIXLY_CORRECT is set, in which case  512-byte  blocks
903              are  used.   See  the  UNUSUAL FILENAMES section for information
904              about how unusual characters in filenames are handled.
905
906
907       -ok command ;
908              Like -exec but ask the user first.  If the user agrees, run  the
909              command.   Otherwise  just return false.  If the command is run,
910              its standard input is redirected from /dev/null.
911
912
913              The response to the prompt is matched against a pair of  regular
914              expressions to determine if it is an affirmative or negative re‐
915              sponse.  This regular expression is obtained from the system  if
916              the  `POSIXLY_CORRECT' environment variable is set, or otherwise
917              from find's message translations.  If the system has no suitable
918              definition, find's own definition will be used.  In either case,
919              the interpretation of the regular expression itself will be  af‐
920              fected   by  the  environment  variables  'LC_CTYPE'  (character
921              classes) and  'LC_COLLATE'  (character  ranges  and  equivalence
922              classes).
923
924
925
926
927       -okdir command ;
928              Like -execdir but ask the user first in the same way as for -ok.
929              If the user does not agree, just return false.  If  the  command
930              is run, its standard input is redirected from /dev/null.
931
932
933       -print True;  print the full file name on the standard output, followed
934              by a newline.  If you are piping the output of find into another
935              program  and  there  is  the faintest possibility that the files
936              which you are searching for might contain a  newline,  then  you
937              should  seriously  consider  using the -print0 option instead of
938              -print.  See the UNUSUAL FILENAMES section for information about
939              how unusual characters in filenames are handled.
940
941
942       -print0
943              True;  print the full file name on the standard output, followed
944              by a null character  (instead  of  the  newline  character  that
945              -print  uses).   This allows file names that contain newlines or
946              other types of white space to be correctly interpreted  by  pro‐
947              grams  that process the find output.  This option corresponds to
948              the -0 option of xargs.
949
950
951       -printf format
952              True; print format on the standard output, interpreting `\'  es‐
953              capes  and  `%'  directives.  Field widths and precisions can be
954              specified as with the printf(3) C function.   Please  note  that
955              many  of  the  fields are printed as %s rather than %d, and this
956              may mean that flags don't work as you might expect.   This  also
957              means  that the `-' flag does work (it forces fields to be left-
958              aligned).  Unlike -print, -printf does not add a newline at  the
959              end of the string.  The escapes and directives are:
960
961              \a     Alarm bell.
962
963              \b     Backspace.
964
965              \c     Stop  printing from this format immediately and flush the
966                     output.
967
968              \f     Form feed.
969
970              \n     Newline.
971
972              \r     Carriage return.
973
974              \t     Horizontal tab.
975
976              \v     Vertical tab.
977
978              \0     ASCII NUL.
979
980              \\     A literal backslash (`\').
981
982              \NNN   The character whose ASCII code is NNN (octal).
983
984              A `\' character followed by any other character is treated as an
985              ordinary character, so they both are printed.
986
987              %%     A literal percent sign.
988
989              %a     File's  last  access time in the format returned by the C
990                     ctime(3) function.
991
992              %Ak    File's last access time in the  format  specified  by  k,
993                     which  is either `@' or a directive for the C strftime(3)
994                     function.  The following shows an incomplete list of pos‐
995                     sible values for k.  Please refer to the documentation of
996                     strftime(3) for the full list.  Some  of  the  conversion
997                     specification  characters  might  not be available on all
998                     systems, due to differences in the implementation of  the
999                     strftime(3) library function.
1000
1001                     @      seconds  since Jan. 1, 1970, 00:00 GMT, with frac‐
1002                            tional part.
1003
1004                     Time fields:
1005
1006                     H      hour (00..23)
1007
1008                     I      hour (01..12)
1009
1010                     k      hour ( 0..23)
1011
1012                     l      hour ( 1..12)
1013
1014                     M      minute (00..59)
1015
1016                     p      locale's AM or PM
1017
1018                     r      time, 12-hour (hh:mm:ss [AP]M)
1019
1020                     S      Second (00.00 .. 61.00).  There  is  a  fractional
1021                            part.
1022
1023                     T      time, 24-hour (hh:mm:ss.xxxxxxxxxx)
1024
1025                     +      Date  and  time,  separated  by  `+',  for example
1026                            `2004-04-28+22:22:05.0'.  This is a GNU extension.
1027                            The  time  is given in the current timezone (which
1028                            may be affected  by  setting  the  TZ  environment
1029                            variable).   The  seconds  field  includes a frac‐
1030                            tional part.
1031
1032                     X      locale's time representation (H:M:S).  The seconds
1033                            field includes a fractional part.
1034
1035                     Z      time  zone (e.g., EDT), or nothing if no time zone
1036                            is determinable
1037
1038                     Date fields:
1039
1040                     a      locale's abbreviated weekday name (Sun..Sat)
1041
1042                     A      locale's full weekday name, variable length  (Sun‐
1043                            day..Saturday)
1044
1045                     b      locale's abbreviated month name (Jan..Dec)
1046
1047                     B      locale's  full  month name, variable length (Janu‐
1048                            ary..December)
1049
1050                     c      locale's date and time (Sat Nov  04  12:02:33  EST
1051                            1989).  The format is the same as for ctime(3) and
1052                            so to preserve  compatibility  with  that  format,
1053                            there is no fractional part in the seconds field.
1054
1055                     d      day of month (01..31)
1056
1057                     D      date (mm/dd/yy)
1058
1059                     F      date (yyyy-mm-dd)
1060
1061                     h      same as b
1062
1063                     j      day of year (001..366)
1064
1065                     m      month (01..12)
1066
1067                     U      week  number  of  year with Sunday as first day of
1068                            week (00..53)
1069
1070                     w      day of week (0..6)
1071
1072                     W      week number of year with Monday as  first  day  of
1073                            week (00..53)
1074
1075                     x      locale's date representation (mm/dd/yy)
1076
1077                     y      last two digits of year (00..99)
1078
1079                     Y      year (1970...)
1080
1081              %b     The  amount  of disk space used for this file in 512-byte
1082                     blocks.  Since disk space is allocated  in  multiples  of
1083                     the  filesystem  block  size this is usually greater than
1084                     %s/512, but it can also be  smaller  if  the  file  is  a
1085                     sparse file.
1086
1087              %c     File's  last status change time in the format returned by
1088                     the C ctime(3) function.
1089
1090              %Ck    File's last status change time in the format specified by
1091                     k, which is the same as for %A.
1092
1093              %d     File's depth in the directory tree; 0 means the file is a
1094                     starting-point.
1095
1096              %D     The device number on which the file  exists  (the  st_dev
1097                     field of struct stat), in decimal.
1098
1099              %f     Print  the basename; the file's name with any leading di‐
1100                     rectories removed (only the last element).   For  /,  the
1101                     result is `/'.  See the EXAMPLES section for an example.
1102
1103
1104              %F     Type  of the filesystem the file is on; this value can be
1105                     used for -fstype.
1106
1107              %g     File's group name, or numeric group ID if the  group  has
1108                     no name.
1109
1110              %G     File's numeric group ID.
1111
1112              %h     Dirname;  the Leading directories of the file's name (all
1113                     but the last element).  If  the  file  name  contains  no
1114                     slashes  (since  it  is  in the current directory) the %h
1115                     specifier expands to `.'.  For files which are themselves
1116                     directories and contain a slash (including /), %h expands
1117                     to the empty string.  See the EXAMPLES section for an ex‐
1118                     ample.
1119
1120              %H     Starting-point under which file was found.
1121
1122              %i     File's inode number (in decimal).
1123
1124              %k     The  amount  of  disk  space  used  for this file in 1 KB
1125                     blocks.  Since disk space is allocated  in  multiples  of
1126                     the  filesystem  block  size this is usually greater than
1127                     %s/1024, but it can also be smaller  if  the  file  is  a
1128                     sparse file.
1129
1130              %l     Object  of  symbolic  link (empty string if file is not a
1131                     symbolic link).
1132
1133              %m     File's permission bits (in octal).  This option uses  the
1134                     `traditional'  numbers  which  most  Unix implementations
1135                     use, but if your particular implementation  uses  an  un‐
1136                     usual  ordering of octal permissions bits, you will see a
1137                     difference between the actual value of  the  file's  mode
1138                     and  the  output of %m.  Normally you will want to have a
1139                     leading zero on this number, and to do this,  you  should
1140                     use the # flag (as in, for example, `%#m').
1141
1142              %M     File's  permissions  (in symbolic form, as for ls).  This
1143                     directive is supported in findutils 4.2.5 and later.
1144
1145              %n     Number of hard links to file.
1146
1147              %p     File's name.
1148
1149              %P     File's name with the name  of  the  starting-point  under
1150                     which it was found removed.
1151
1152              %s     File's size in bytes.
1153
1154              %S     File's   sparseness.    This  is  calculated  as  (BLOCK‐
1155                     SIZE*st_blocks / st_size).  The exact value you will  get
1156                     for an ordinary file of a certain length is system-depen‐
1157                     dent.  However, normally sparse files  will  have  values
1158                     less  than  1.0,  and files which use indirect blocks may
1159                     have a value which is greater than 1.0.  In  general  the
1160                     number of blocks used by a file is file system dependent.
1161                     The value used for BLOCKSIZE is system-dependent, but  is
1162                     usually  512  bytes.  If the file size is zero, the value
1163                     printed is undefined.  On systems which lack support  for
1164                     st_blocks, a file's sparseness is assumed to be 1.0.
1165
1166              %t     File's  last  modification time in the format returned by
1167                     the C ctime(3) function.
1168
1169              %Tk    File's last modification time in the format specified  by
1170                     k, which is the same as for %A.
1171
1172              %u     File's  user  name, or numeric user ID if the user has no
1173                     name.
1174
1175              %U     File's numeric user ID.
1176
1177              %y     File's type (like in ls -l),  U=unknown  type  (shouldn't
1178                     happen)
1179
1180              %Y     File's  type  (like  %y),  plus  follow  symbolic  links:
1181                     `L'=loop, `N'=nonexistent, `?' for any other  error  when
1182                     determining the type of the target of a symbolic link.
1183
1184              %Z     (SELinux only) file's security context.
1185
1186              %{ %[ %(
1187                     Reserved for future use.
1188
1189              A  `%'  character  followed by any other character is discarded,
1190              but the other character is printed (don't rely on this, as  fur‐
1191              ther  format characters may be introduced).  A `%' at the end of
1192              the format argument causes undefined behaviour since there is no
1193              following  character.   In  some  locales, it may hide your door
1194              keys, while in others it may remove  the  final  page  from  the
1195              novel you are reading.
1196
1197              The  %m  and %d directives support the #, 0 and + flags, but the
1198              other directives do not, even if they  print  numbers.   Numeric
1199              directives that do not support these flags include G, U, b, D, k
1200              and n.  The `-' format flag is supported and changes the  align‐
1201              ment  of  a field from right-justified (which is the default) to
1202              left-justified.
1203
1204              See the UNUSUAL FILENAMES section for information about how  un‐
1205              usual characters in filenames are handled.
1206
1207
1208
1209       -prune True;  if  the  file is a directory, do not descend into it.  If
1210              -depth is given, then -prune has no effect.  Because -delete im‐
1211              plies  -depth,  you  cannot  usefully use -prune and -delete to‐
1212              gether.  For example, to skip the directory  src/emacs  and  all
1213              files and directories under it, and print the names of the other
1214              files found, do something like this:
1215                  find . -path ./src/emacs -prune -o -print
1216
1217
1218
1219       -quit  Exit immediately (with return value zero if no errors  have  oc‐
1220              curred).   This  is  different to -prune because -prune only ap‐
1221              plies to the contents of pruned directories, while -quit  simply
1222              makes  find  stop  immediately.  No child processes will be left
1223              running.  Any command lines which have been built by -exec ... +
1224              or -execdir ... + are invoked before the program is exited.  Af‐
1225              ter -quit is executed, no more files specified  on  the  command
1226              line       will       be      processed.       For      example,
1227              `find /tmp/foo /tmp/bar -print -quit`    will     print     only
1228              `/tmp/foo`.
1229              One  common  use  of  -quit is to stop searching the file system
1230              once we have found what we want.  For example,  if  we  want  to
1231              find just a single file we can do this:
1232                  find / -name needle -print -quit
1233
1234
1235   OPERATORS
1236       Listed in order of decreasing precedence:
1237
1238
1239       ( expr )
1240              Force  precedence.   Since parentheses are special to the shell,
1241              you will normally need to quote them.  Many of the  examples  in
1242              this manual page use backslashes for this purpose: `\(...\)' in‐
1243              stead of `(...)'.
1244
1245
1246       ! expr True if expr is false.  This character will  also  usually  need
1247              protection from interpretation by the shell.
1248
1249
1250       -not expr
1251              Same as ! expr, but not POSIX compliant.
1252
1253
1254       expr1 expr2
1255              Two  expressions in a row are taken to be joined with an implied
1256              -a; expr2 is not evaluated if expr1 is false.
1257
1258
1259       expr1 -a expr2
1260              Same as expr1 expr2.
1261
1262
1263       expr1 -and expr2
1264              Same as expr1 expr2, but not POSIX compliant.
1265
1266
1267       expr1 -o expr2
1268              Or; expr2 is not evaluated if expr1 is true.
1269
1270
1271       expr1 -or expr2
1272              Same as expr1 -o expr2, but not POSIX compliant.
1273
1274
1275       expr1 , expr2
1276              List; both expr1 and expr2 are always evaluated.  The  value  of
1277              expr1 is discarded; the value of the list is the value of expr2.
1278              The comma operator can be useful for searching for several  dif‐
1279              ferent  types  of thing, but traversing the filesystem hierarchy
1280              only once.  The -fprintf action can be used to list the  various
1281              matched items into several different output files.
1282
1283       Please note that -a when specified implicitly (for example by two tests
1284       appearing without an explicit operator between them) or explicitly  has
1285       higher precedence than -o.  This means that find . -name afile -o -name
1286       bfile -print will never print afile.
1287

UNUSUAL FILENAMES

1289       Many of the actions of find result in the printing of data which is un‐
1290       der the control of other users.  This includes file names, sizes, modi‐
1291       fication times and so forth.  File names are a potential problem  since
1292       they can contain any character except `\0' and `/'.  Unusual characters
1293       in file names can do unexpected and often undesirable  things  to  your
1294       terminal  (for  example, changing the settings of your function keys on
1295       some terminals).  Unusual characters are handled differently by various
1296       actions, as described below.
1297
1298
1299       -print0, -fprint0
1300              Always  print  the exact filename, unchanged, even if the output
1301              is going to a terminal.
1302
1303
1304       -ls, -fls
1305              Unusual characters are always escaped.  White space,  backslash,
1306              and  double  quote characters are printed using C-style escaping
1307              (for example `\f', `\"').  Other unusual characters are  printed
1308              using  an octal escape.  Other printable characters (for -ls and
1309              -fls these are the characters between octal 041  and  0176)  are
1310              printed as-is.
1311
1312
1313       -printf, -fprintf
1314              If  the  output is not going to a terminal, it is printed as-is.
1315              Otherwise, the result depends on which directive is in use.  The
1316              directives %D, %F, %g, %G, %H, %Y, and %y expand to values which
1317              are not under control of files' owners, and so are  printed  as-
1318              is.   The directives %a, %b, %c, %d, %i, %k, %m, %M, %n, %s, %t,
1319              %u and %U have values which are under the control of files' own‐
1320              ers  but which cannot be used to send arbitrary data to the ter‐
1321              minal, and so these are printed as-is.  The directives  %f,  %h,
1322              %l, %p and %P are quoted.  This quoting is performed in the same
1323              way as for GNU ls.  This is not the same  quoting  mechanism  as
1324              the  one  used for -ls and -fls.  If you are able to decide what
1325              format to use for the output of find then it is normally  better
1326              to  use  `\0' as a terminator than to use newline, as file names
1327              can contain white space and newline characters.  The setting  of
1328              the  `LC_CTYPE'  environment variable is used to determine which
1329              characters need to be quoted.
1330
1331
1332       -print, -fprint
1333              Quoting is handled in the same way as for -printf and  -fprintf.
1334              If  you  are  using find in a script or in a situation where the
1335              matched files might have arbitrary names,  you  should  consider
1336              using -print0 instead of -print.
1337
1338       The  -ok and -okdir actions print the current filename as-is.  This may
1339       change in a future release.
1340

STANDARDS CONFORMANCE

1342       For closest compliance to  the  POSIX  standard,  you  should  set  the
1343       POSIXLY_CORRECT environment variable.  The following options are speci‐
1344       fied in the POSIX standard (IEEE Std 1003.1-2008, 2016 Edition):
1345
1346
1347       -H     This option is supported.
1348
1349
1350       -L     This option is supported.
1351
1352
1353       -name  This option is supported, but POSIX conformance depends  on  the
1354              POSIX  conformance  of the system's fnmatch(3) library function.
1355              As of findutils-4.2.2, shell metacharacters (`*',  `?'  or  `[]'
1356              for  example) match a leading `.', because IEEE PASC interpreta‐
1357              tion 126 requires this.  This is a change from previous versions
1358              of findutils.
1359
1360
1361       -type  Supported.   POSIX  specifies  `b',  `c', `d', `l', `p', `f' and
1362              `s'.  GNU find also supports `D', representing a Door, where the
1363              OS  provides these.  Furthermore, GNU find allows multiple types
1364              to be specified at once in a comma-separated list.
1365
1366
1367       -ok    Supported.  Interpretation of the response is according  to  the
1368              `yes'  and  `no'  patterns selected by setting the `LC_MESSAGES'
1369              environment variable.  When  the  `POSIXLY_CORRECT'  environment
1370              variable is set, these patterns are taken system's definition of
1371              a positive (yes) or negative (no) response.   See  the  system's
1372              documentation  for nl_langinfo(3), in particular YESEXPR and NO‐
1373              EXPR.  When `POSIXLY_CORRECT' is not set, the patterns  are  in‐
1374              stead taken from find's own message catalogue.
1375
1376
1377       -newer Supported.   If the file specified is a symbolic link, it is al‐
1378              ways dereferenced.  This is a change  from  previous  behaviour,
1379              which used to take the relevant time from the symbolic link; see
1380              the HISTORY section below.
1381
1382
1383       -perm  Supported.  If the POSIXLY_CORRECT environment variable  is  not
1384              set,  some mode arguments (for example +a+x) which are not valid
1385              in POSIX are supported for backward-compatibility.
1386
1387
1388       Other primaries
1389              The primaries -atime, -ctime,  -depth,  -exec,  -group,  -links,
1390              -mtime,  -nogroup,  -nouser,  -ok, -path, -print, -prune, -size,
1391              -user and -xdev are all supported.
1392
1393
1394       The POSIX standard specifies parentheses `(', `)', negation `!' and the
1395       logical AND/OR operators -a and -o.
1396
1397       All  other options, predicates, expressions and so forth are extensions
1398       beyond the POSIX standard.  Many of these extensions are not unique  to
1399       GNU find, however.
1400
1401       The POSIX standard requires that find detects loops:
1402
1403              The  find utility shall detect infinite loops; that is, entering
1404              a previously visited directory that is an ancestor of  the  last
1405              file  encountered.  When it detects an infinite loop, find shall
1406              write a diagnostic message to standard error  and  shall  either
1407              recover its position in the hierarchy or terminate.
1408
1409       GNU  find complies with these requirements.  The link count of directo‐
1410       ries which contain entries which are hard links to an ancestor will of‐
1411       ten  be  lower  than  they otherwise should be.  This can mean that GNU
1412       find will sometimes optimise away the visiting of a subdirectory  which
1413       is  actually a link to an ancestor.  Since find does not actually enter
1414       such a subdirectory, it is allowed to avoid emitting a diagnostic  mes‐
1415       sage.   Although  this  behaviour  may be somewhat confusing, it is un‐
1416       likely that anybody actually depends on this behaviour.   If  the  leaf
1417       optimisation has been turned off with -noleaf, the directory entry will
1418       always be examined and the diagnostic message will be issued  where  it
1419       is appropriate.  Symbolic links cannot be used to create filesystem cy‐
1420       cles as such, but if the -L option or the -follow option is in  use,  a
1421       diagnostic  message  is  issued when find encounters a loop of symbolic
1422       links.  As with loops containing hard links, the leaf optimisation will
1423       often  mean  that  find  knows  that  it doesn't need to call stat() or
1424       chdir() on the symbolic link, so this diagnostic is frequently not nec‐
1425       essary.
1426
1427       The  -d option is supported for compatibility with various BSD systems,
1428       but you should use the POSIX-compliant option -depth instead.
1429
1430       The POSIXLY_CORRECT environment variable does not affect the  behaviour
1431       of  the -regex or -iregex tests because those tests aren't specified in
1432       the POSIX standard.
1433

ENVIRONMENT VARIABLES

1435       LANG   Provides a default value for the internationalization  variables
1436              that are unset or null.
1437
1438
1439       LC_ALL If  set  to a non-empty string value, override the values of all
1440              the other internationalization variables.
1441
1442
1443       LC_COLLATE
1444              The POSIX standard specifies that this variable affects the pat‐
1445              tern  matching  to  be used for the -name option.  GNU find uses
1446              the fnmatch(3) library function, and so support for `LC_COLLATE'
1447              depends  on  the system library.  This variable also affects the
1448              interpretation of the response to -ok; while  the  `LC_MESSAGES'
1449              variable  selects  the  actual pattern used to interpret the re‐
1450              sponse to -ok, the interpretation of any bracket expressions  in
1451              the pattern will be affected by `LC_COLLATE'.
1452
1453
1454       LC_CTYPE
1455              This variable affects the treatment of character classes used in
1456              regular expressions and also with the -name test,  if  the  sys‐
1457              tem's  fnmatch(3) library function supports this.  This variable
1458              also affects the interpretation of any character classes in  the
1459              regular expressions used to interpret the response to the prompt
1460              issued by -ok.  The `LC_CTYPE' environment  variable  will  also
1461              affect  which  characters  are considered to be unprintable when
1462              filenames are printed; see the section UNUSUAL FILENAMES.
1463
1464
1465       LC_MESSAGES
1466              Determines the locale to be used for internationalised messages.
1467              If  the `POSIXLY_CORRECT' environment variable is set, this also
1468              determines the interpretation of the response to the prompt made
1469              by the -ok action.
1470
1471
1472       NLSPATH
1473              Determines the location of the internationalisation message cat‐
1474              alogues.
1475
1476
1477       PATH   Affects the directories which are searched to find the  executa‐
1478              bles invoked by -exec, -execdir, -ok and -okdir.
1479
1480
1481       POSIXLY_CORRECT
1482              Determines the block size used by -ls and -fls.  If POSIXLY_COR‐
1483              RECT is set, blocks are units of 512 bytes.  Otherwise they  are
1484              units of 1024 bytes.
1485
1486              Setting  this variable also turns off warning messages (that is,
1487              implies -nowarn) by default, because POSIX requires  that  apart
1488              from  the output for -ok, all messages printed on stderr are di‐
1489              agnostics and must result in a non-zero exit status.
1490
1491              When POSIXLY_CORRECT is not set, -perm +zzz is treated just like
1492              -perm  /zzz  if  +zzz  is  not  a  valid  symbolic  mode.   When
1493              POSIXLY_CORRECT is set, such constructs are treated as an error.
1494
1495              When POSIXLY_CORRECT is set, the response to the prompt made  by
1496              the  -ok action is interpreted according to the system's message
1497              catalogue, as opposed to according to find's own message  trans‐
1498              lations.
1499
1500
1501       TZ     Affects  the  time zone used for some of the time-related format
1502              directives of -printf and -fprintf.
1503

EXAMPLES

1505   Simple `find|xargs` approach
1506       •      Find files named core in or below the directory /tmp and  delete
1507              them.
1508
1509                  $ find /tmp -name core -type f -print | xargs /bin/rm -f
1510
1511              Note  that this will work incorrectly if there are any filenames
1512              containing newlines, single or double quotes, or spaces.
1513
1514   Safer `find -print0 | xargs -0` approach
1515       •      Find files named core in or below the directory /tmp and  delete
1516              them,  processing filenames in such a way that file or directory
1517              names containing single or double quotes, spaces or newlines are
1518              correctly handled.
1519
1520                  $ find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
1521
1522              The  -name  test  comes  before the -type test in order to avoid
1523              having to call stat(2) on every file.
1524
1525       Note that there is still a race between the time find traverses the hi‐
1526       erarchy  printing the matching filenames, and the time the process exe‐
1527       cuted by xargs works with that file.
1528
1529
1530   Executing a command for each file
1531       •      Run file on every file in or below the current directory.
1532
1533                  $ find . -type f -exec file '{}' \;
1534
1535              Notice that the braces are enclosed in  single  quote  marks  to
1536              protect  them  from  interpretation as shell script punctuation.
1537              The semicolon is similarly protected by the use of a  backslash,
1538              though single quotes could have been used in that case also.
1539
1540       In  many  cases, one might prefer the `-exec ... +` or better the `-ex‐
1541       ecdir ... +` syntax for performance and security reasons.
1542
1543   Traversing the filesystem just once - for 2 different actions
1544       •      Traverse the filesystem just once, listing set-user-ID files and
1545              directories   into   /root/suid.txt   and   large   files   into
1546              /root/big.txt.
1547
1548                  $ find / \
1549                      \( -perm -4000 -fprintf /root/suid.txt '%#m %u %p\n' \) , \
1550                      \( -size +100M -fprintf /root/big.txt '%-10s %p\n' \)
1551
1552              This example uses the line-continuation  character  '\'  on  the
1553              first  two  lines  to instruct the shell to continue reading the
1554              command on the next line.
1555
1556   Searching files by age
1557       •      Search for files in your home directory which have been modified
1558              in the last twenty-four hours.
1559
1560                  $ find $HOME -mtime 0
1561
1562              This command works this way because the time since each file was
1563              last modified is divided by 24 hours and any remainder  is  dis‐
1564              carded.   That means that to match -mtime 0, a file will have to
1565              have a modification in the past which is less than 24 hours ago.
1566
1567   Searching files by permissions
1568       •      Search for files which are executable but not readable.
1569
1570                  $ find /sbin /usr/sbin -executable \! -readable -print
1571
1572
1573       •      Search for files which have read and write permission for  their
1574              owner,  and  group, but which other users can read but not write
1575              to.
1576
1577                  $ find . -perm 664
1578
1579              Files which meet these criteria but have other permissions  bits
1580              set  (for  example  if someone can execute the file) will not be
1581              matched.
1582
1583       •      Search for files which have read and write permission for  their
1584              owner  and group, and which other users can read, without regard
1585              to the presence of any extra permission bits  (for  example  the
1586              executable bit).
1587
1588                  $ find . -perm -664
1589
1590              This will match a file which has mode 0777, for example.
1591
1592       •      Search for files which are writable by somebody (their owner, or
1593              their group, or anybody else).
1594
1595                  $ find . -perm /222
1596
1597
1598       •      Search for files which are writable by  either  their  owner  or
1599              their group.
1600
1601                  $ find . -perm /220
1602                  $ find . -perm /u+w,g+w
1603                  $ find . -perm /u=w,g=w
1604
1605              All three of these commands do the same thing, but the first one
1606              uses the octal representation of the file mode,  and  the  other
1607              two  use the symbolic form.  The files don't have to be writable
1608              by both the owner and group to be matched; either will do.
1609
1610       •      Search for files which are writable  by  both  their  owner  and
1611              their group.
1612
1613                  $ find . -perm -220
1614                  $ find . -perm -g+w,u+w
1615
1616              Both these commands do the same thing.
1617
1618       •      A more elaborate search on permissions.
1619
1620                  $ find . -perm -444 -perm /222 \! -perm /111
1621                  $ find . -perm -a+r -perm /a+w \! -perm /a+x
1622
1623              These  two  commands both search for files that are readable for
1624              everybody (-perm -444 or -perm -a+r), have at  least  one  write
1625              bit  set  (-perm  /222 or -perm /a+w) but are not executable for
1626              anybody (! -perm /111 or ! -perm /a+x respectively).
1627
1628   Pruning - omitting files and subdirectories
1629       •      Copy the contents of /source-dir to /dest-dir,  but  omit  files
1630              and directories named .snapshot (and anything in them).  It also
1631              omits files or directories whose name ends in '~', but not their
1632              contents.
1633
1634                  $ cd /source-dir
1635                  $ find . -name .snapshot -prune -o \( \! -name '*~' -print0 \) \
1636                      | cpio -pmd0 /dest-dir
1637
1638              The  construct -prune -o \( ... -print0 \) is quite common.  The
1639              idea here is that the expression before  -prune  matches  things
1640              which  are  to be pruned.  However, the -prune action itself re‐
1641              turns true, so the following -o ensures that the right hand side
1642              is  evaluated only for those directories which didn't get pruned
1643              (the contents of the pruned directories are not even visited, so
1644              their  contents  are  irrelevant).   The expression on the right
1645              hand side of the -o is in parentheses only for clarity.  It  em‐
1646              phasises  that  the  -print0  action takes place only for things
1647              that didn't have -prune applied to them.   Because  the  default
1648              `and'  condition  between tests binds more tightly than -o, this
1649              is the default anyway, but the parentheses help to show what  is
1650              going on.
1651
1652       •      Given  the  following directory of projects and their associated
1653              SCM administrative directories, perform an efficient search  for
1654              the projects' roots:
1655
1656                  $ find repo/ \
1657                      \( -exec test -d '{}/.svn' \; \
1658                      -or -exec test -d '{}/.git' \; \
1659                      -or -exec test -d '{}/CVS' \; \
1660                      \) -print -prune
1661
1662              Sample output:
1663
1664                  repo/project1/CVS
1665                  repo/gnu/project2/.svn
1666                  repo/gnu/project3/.svn
1667                  repo/gnu/project3/src/.svn
1668                  repo/project4/.git
1669
1670              In this example, -prune prevents unnecessary descent into direc‐
1671              tories that have already been discovered (for example we do  not
1672              search project3/src because we already found project3/.svn), but
1673              ensures sibling directories (project2 and project3) are found.
1674
1675   Other useful examples
1676       •      Search for several file types.
1677
1678                  $ find /tmp -type f,d,l
1679
1680              Search for files, directories, and symbolic links in the  direc‐
1681              tory /tmp passing these types as a comma-separated list (GNU ex‐
1682              tension), which is otherwise equivalent to the longer, yet  more
1683              portable:
1684
1685                  $ find /tmp \( -type f -o -type d -o -type l \)
1686
1687
1688       •      Search  for files with the particular name needle and stop imme‐
1689              diately when we find the first one.
1690
1691                  $ find / -name needle -print -quit
1692
1693
1694       •      Demonstrate the interpretation of the %f and  %h  format  direc‐
1695              tives  of  the -printf action for some corner-cases.  Here is an
1696              example including some output.
1697
1698                  $ find . .. / /tmp /tmp/TRACE compile compile/64/tests/find -maxdepth 0 -printf '[%h][%f]\n'
1699                  [.][.]
1700                  [.][..]
1701                  [][/]
1702                  [][tmp]
1703                  [/tmp][TRACE]
1704                  [.][compile]
1705                  [compile/64/tests][find]
1706
1707

EXIT STATUS

1709       find exits with status 0  if  all  files  are  processed  successfully,
1710       greater  than 0 if errors occur.  This is deliberately a very broad de‐
1711       scription, but if the return value is non-zero, you should not rely  on
1712       the correctness of the results of find.
1713
1714       When  some  error occurs, find may stop immediately, without completing
1715       all the actions specified.  For example, some starting points  may  not
1716       have   been   examined   or   some   pending  program  invocations  for
1717       -exec ... {} + or -execdir ... {} + may not have been performed.
1718

HISTORY

1720       As of findutils-4.2.2, shell metacharacters (`*', `?' or `[]' for exam‐
1721       ple)  used in filename patterns match a leading `.', because IEEE POSIX
1722       interpretation 126 requires this.
1723
1724       As of findutils-4.3.3, -perm /000 now  matches  all  files  instead  of
1725       none.
1726
1727       Nanosecond-resolution timestamps were implemented in findutils-4.3.3.
1728
1729       As of findutils-4.3.11, the -delete action sets find's exit status to a
1730       nonzero value when it fails.  However, find will not exit  immediately.
1731       Previously,  find's  exit  status  was  unaffected  by  the  failure of
1732       -delete.
1733
1734       Feature                Added in   Also occurs in
1735       -newerXY               4.3.3      BSD
1736       -D                     4.3.1
1737       -O                     4.3.1
1738       -readable              4.3.0
1739       -writable              4.3.0
1740       -executable            4.3.0
1741       -regextype             4.2.24
1742       -exec ... +            4.2.12     POSIX
1743       -execdir               4.2.12     BSD
1744       -okdir                 4.2.12
1745       -samefile              4.2.11
1746       -H                     4.2.5      POSIX
1747       -L                     4.2.5      POSIX
1748       -P                     4.2.5      BSD
1749       -delete                4.2.3
1750       -quit                  4.2.3
1751       -d                     4.2.3      BSD
1752       -wholename             4.2.0
1753       -iwholename            4.2.0
1754       -ignore_readdir_race   4.2.0
1755       -fls                   4.0
1756       -ilname                3.8
1757       -iname                 3.8
1758       -ipath                 3.8
1759       -iregex                3.8
1760
1761       The syntax -perm +MODE was removed in findutils-4.5.12,  in  favour  of
1762       -perm  /MODE.   The  +MODE  syntax  had  been  deprecated  since findu‐
1763       tils-4.2.21 which was released in 2005.
1764

NON-BUGS

1766   Operator precedence surprises
1767       The command find . -name afile -o -name bfile -print will  never  print
1768       afile  because  this is actually equivalent to find . -name afile -o \(
1769       -name bfile -a -print \).  Remember that the precedence of -a is higher
1770       than  that of -o and when there is no operator specified between tests,
1771       -a is assumed.
1772
1773   “paths must precede expression” error message
1774       $ find . -name *.c -print
1775       find: paths must precede expression
1776       find: possible unquoted pattern after predicate `-name'?
1777
1778       This happens when the shell could expand the pattern *.c to  more  than
1779       one  file  name  existing in the current directory, and passing the re‐
1780       sulting file names in the command line to find like this:
1781       find . -name frcode.c locate.c word_io.c -print
1782       That command is of course not going to work, because the  -name  predi‐
1783       cate  allows  exactly  only  one pattern as argument.  Instead of doing
1784       things this way, you should enclose the pattern in quotes or escape the
1785       wildcard,  thus allowing find to use the pattern with the wildcard dur‐
1786       ing the search for file name matching instead of file names expanded by
1787       the parent shell:
1788       $ find . -name '*.c' -print
1789       $ find . -name \*.c -print
1790

BUGS

1792       There  are  security  problems inherent in the behaviour that the POSIX
1793       standard specifies for find, which therefore cannot be fixed.  For  ex‐
1794       ample,  the -exec action is inherently insecure, and -execdir should be
1795       used instead.
1796
1797       The environment variable LC_COLLATE has no effect on the -ok action.
1798

REPORTING BUGS

1800       GNU   findutils   online   help:   <https://www.gnu.org/software/findu
1801       tils/#get-help>
1802       Report any translation bugs to <https://translationproject.org/team/>
1803
1804       Report any other issue via the form at the GNU Savannah bug tracker:
1805              <https://savannah.gnu.org/bugs/?group=findutils>
1806       General  topics  about  the  GNU findutils package are discussed at the
1807       bug-findutils mailing list:
1808              <https://lists.gnu.org/mailman/listinfo/bug-findutils>
1809
1811       Copyright © 1990-2021 Free Software Foundation, Inc.   License  GPLv3+:
1812       GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
1813       This  is  free  software:  you  are free to change and redistribute it.
1814       There is NO WARRANTY, to the extent permitted by law.
1815

SEE ALSO

1817       chmod(1), locate(1), ls(1), updatedb(1), xargs(1),  lstat(2),  stat(2),
1818       ctime(3) fnmatch(3), printf(3), strftime(3), locatedb(5), regex(7)
1819
1820       Full documentation <https://www.gnu.org/software/findutils/find>
1821       or available locally via: info find
1822
1823
1824
1825                                                                       FIND(1)
Impressum