1.\" Copyright (c) 1990, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" the Institute of Electrical and Electronics Engineers, Inc. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.Dd February 14, 2026 32.Dt FIND 1 33.Os 34.Sh NAME 35.Nm find 36.Nd walk a file hierarchy 37.Sh SYNOPSIS 38.Nm 39.Op Fl H | Fl L | Fl P 40.Op Fl EXdsx 41.Op Fl f Ar path 42.Ar path ... 43.Op Ar expression 44.Nm 45.Op Fl H | Fl L | Fl P 46.Op Fl EXdsx 47.Fl f Ar path 48.Op Ar path ... 49.Op Ar expression 50.Sh DESCRIPTION 51The 52.Nm 53utility recursively descends the directory tree for each 54.Ar path 55listed, evaluating an 56.Ar expression 57(composed of the 58.Dq primaries 59and 60.Dq operands 61listed below) in terms 62of each file in the tree. 63.Pp 64The options are as follows: 65.Bl -tag -width indent 66.It Fl E 67Interpret regular expressions following the 68.Ic -regex 69and 70.Ic -iregex 71primaries as extended (modern) regular expressions rather than basic 72regular expressions (BRE's). 73The 74.Xr re_format 7 75manual page fully describes both formats. 76.It Fl H 77Cause the file information and file type (see 78.Xr stat 2 ) 79returned for each symbolic link specified on the command line to be 80those of the file referenced by the link, not the link itself. 81If the referenced file does not exist, the file information and type will 82be for the link itself. 83File information of all symbolic links not on 84the command line is that of the link itself. 85.It Fl L 86Cause the file information and file type (see 87.Xr stat 2 ) 88returned for each symbolic link to be those of the file referenced by the 89link, not the link itself. 90If the referenced file does not exist, the file information and type will 91be for the link itself. 92.Pp 93This option is equivalent to the deprecated 94.Ic -follow 95primary. 96.It Fl P 97Cause the file information and file type (see 98.Xr stat 2 ) 99returned for each symbolic link to be those of the link itself. 100This is the default. 101.It Fl X 102Permit 103.Nm 104to be safely used in conjunction with 105.Xr xargs 1 . 106If a file name contains any of the delimiting characters used by 107.Xr xargs 1 , 108a diagnostic message is displayed on standard error, and the file 109is skipped. 110The delimiting characters include single 111.Pq Dq Li " ' " 112and double 113.Pq Dq Li " \*q " 114quotes, backslash 115.Pq Dq Li \e , 116space, tab and newline characters. 117.Pp 118However, you may wish to consider the 119.Fl print0 120primary in conjunction with 121.Dq Nm xargs Fl 0 122as an effective alternative. 123.It Fl d 124Cause 125.Nm 126to perform a depth-first traversal. 127.Pp 128This option is a BSD-specific equivalent of the 129.Ic -depth 130primary specified by 131.St -p1003.1-2001 . 132Refer to its description under 133.Sx PRIMARIES 134for more information. 135.It Fl f Ar path 136Add 137.Ar path 138to the list of paths that will be recursed into. 139This is useful when 140.Ar path 141begins with a character that would otherwise be interpreted as an 142.Ar expression , 143namely 144.Dq Li "!" , 145.Dq Li "(" 146and 147.Dq Li - . 148.It Fl s 149Cause 150.Nm 151to traverse the file hierarchies in lexicographical order, 152i.e., alphabetical order within each directory. 153Note: 154.Ql find -s 155and 156.Ql "find | sort" 157may give different results. 158.Pp 159For example, 160.Ql find -s 161puts a directory 162.Ql Ar foo 163with all its contents before a directory 164.Ql Ar foo.\& 165but 166.Ql "find | sort" 167puts the directory name 168.Ql Ar foo.\& 169before any string like 170.Ql Ar foo/bar 171because 172.Ql .\& 173goes before 174.Ql / 175in ASCII. 176In locales other than 177.Ar C 178results may vary more due to collation differences. 179.It Fl x 180Prevent 181.Nm 182from descending into directories that have a device number different 183than that of the file from which the descent began. 184.Pp 185This option is equivalent to the deprecated 186.Ic -xdev 187primary. 188.El 189.Sh PRIMARIES 190All primaries which take a numeric argument allow the number to be 191preceded by a plus sign 192.Pq Dq Li + 193or a minus sign 194.Pq Dq Li - . 195A preceding plus sign means 196.Dq more than n , 197a preceding minus sign means 198.Dq less than n 199and neither means 200.Dq exactly n . 201.Bl -tag -width indent 202.It Ic -Bmin Ar n 203True if the difference between the time of a file's inode creation 204and the time 205.Nm 206was started, rounded up to the next full minute, is 207.Ar n 208minutes. 209.It Ic -Bnewer Ar file 210Same as 211.Ic -newerBm . 212.It Ic -Btime Ar n Ns Op Cm smhdw 213If no units are specified, this primary evaluates to 214true if the difference between the time of a file's inode creation 215and the time 216.Nm 217was started, rounded up to the next full 24-hour period, is 218.Ar n 21924-hour periods. 220.Pp 221If units are specified, this primary evaluates to 222true if the difference between the time of a file's inode creation 223and the time 224.Nm 225was started is exactly 226.Ar n 227units. 228Please refer to the 229.Ic -atime 230primary description for information on supported time units. 231.It Ic -acl 232May be used in conjunction with other primaries to locate 233files with extended ACLs. 234See 235.Xr acl 3 236for more information. 237.It Ic -amin Oo Cm - Ns | Ns Cm + Oc Ns Ar n 238True if the difference between the file last access time and the time 239.Nm 240was started, rounded up to the next full minute, is 241more than 242.Ar n 243.Pq + Ns Ar n , 244less than 245.Ar n 246.Pq - Ns Ar n , 247or exactly 248.Ar n 249minutes ago. 250.It Ic -anewer Ar file 251Same as 252.Ic -neweram . 253.It Ic -atime Ar n Ns Op Cm smhdw 254If no units are specified, this primary evaluates to 255true if the difference between the file last access time and the time 256.Nm 257was started, rounded up to the next full 24-hour period, is 258.Ar n 25924-hour periods. 260.Pp 261If units are specified, this primary evaluates to 262true if the difference between the file last access time and the time 263.Nm 264was started is exactly 265.Ar n 266units. 267Possible time units are as follows: 268.Pp 269.Bl -tag -width indent -compact 270.It Cm s 271second 272.It Cm m 273minute (60 seconds) 274.It Cm h 275hour (60 minutes) 276.It Cm d 277day (24 hours) 278.It Cm w 279week (7 days) 280.El 281.Pp 282Any number of units may be combined in one 283.Ic -atime 284argument, for example, 285.Dq Li "-atime -1h30m" . 286Units are probably only useful when used in conjunction with the 287.Cm + 288or 289.Cm - 290modifier. 291.It Ic -cmin Oo Cm - Ns | Ns Cm + Oc Ns Ar n 292True if the difference between the time of last change of file status 293information and the time 294.Nm 295was started, rounded up to the next full minute, is 296more than 297.Ar n 298.Pq + Ns Ar n , 299less than 300.Ar n 301.Pq - Ns Ar n , 302or exactly 303.Ar n 304minutes ago. 305.It Ic -cnewer Ar file 306Same as 307.Ic -newercm . 308.It Ic -ctime Ar n Ns Op Cm smhdw 309If no units are specified, this primary evaluates to 310true if the difference between the time of last change of file status 311information and the time 312.Nm 313was started, rounded up to the next full 24-hour period, is 314.Ar n 31524-hour periods. 316.Pp 317If units are specified, this primary evaluates to 318true if the difference between the time of last change of file status 319information and the time 320.Nm 321was started is exactly 322.Ar n 323units. 324Please refer to the 325.Ic -atime 326primary description for information on supported time units. 327.It Ic -d 328Non-portable, BSD-specific version of 329.Ic depth . 330GNU find implements this as a primary in mistaken emulation of 331.Fx 332.Nm . 333.It Ic -delete 334Delete found files and/or directories. 335Always returns true. 336This executes 337from the current working directory as 338.Nm 339recurses down the tree. 340It will not attempt to delete a filename with a 341.Dq Pa / 342character in its pathname relative to 343.Dq Pa \&. 344for security reasons. 345Depth-first traversal processing is implied by this option. 346The 347.Ic -delete 348primary will fail to delete a directory if it is not empty. 349Following symlinks is incompatible with this option. 350.Pp 351.Em WARNING : 352The 353.Ic -delete 354primary will immediately attempt to delete the current path when 355evaluated. 356Be mindful of its place in the expression; as a general rule, it 357should almost always come last. 358If in doubt, try running with 359.Ic -print 360in place of 361.Ic -delete 362first. 363See 364.Sx OPERATORS 365below for additional information on the order of evaluation. 366.It Ic -depth 367Always true; 368same as the non-portable 369.Fl d 370option. 371Cause 372.Nm 373to perform a depth-first traversal, i.e., directories 374are visited in post-order and all entries in a directory will be acted 375on before the directory itself. 376By default, 377.Nm 378visits directories in pre-order, i.e., before their contents. 379Note, the default is 380.Em not 381a breadth-first traversal. 382.Pp 383The 384.Ic -depth 385primary 386can be useful when 387.Nm 388is used with 389.Xr cpio 1 390to process files that are contained in directories with unusual permissions. 391It ensures that you have write permission while you are placing files in a 392directory, then sets the directory's permissions as the last thing. 393.It Ic -depth Ar n 394True if the depth of the file relative to the starting point of the traversal 395is 396.Ar n . 397.It Ic -empty 398True if the current file or directory is empty. 399.It Ic -exec Ar utility Oo Ar argument ... Oc Li \&; 400True if the program named 401.Ar utility 402returns a zero value as its exit status. 403Optional 404.Ar arguments 405may be passed to the utility. 406The expression must be terminated by a semicolon 407.Pq Dq Li \&; . 408If you invoke 409.Nm 410from a shell you may need to quote the semicolon if the shell would 411otherwise treat it as a control operator. 412If the string 413.Dq Li {} 414appears anywhere in the utility name or the 415arguments it is replaced by the pathname of the current file. 416.Ar Utility 417will be executed from the directory from which 418.Nm 419was executed. 420.Ar Utility 421and 422.Ar arguments 423are not subject to the further expansion of shell patterns 424and constructs. 425.It Ic -exec Ar utility Oo Ar argument ... Oc Li {} + 426Same as 427.Ic -exec , 428except that 429.Dq Li {} 430is replaced with as many pathnames as possible for each invocation of 431.Ar utility . 432This behaviour is similar to that of 433.Xr xargs 1 . 434The primary always returns true; 435if at least one invocation of 436.Ar utility 437returns a non-zero exit status, 438.Nm 439will return a non-zero exit status. 440.It Ic -execdir Ar utility Oo Ar argument ... Oc Li \&; 441The 442.Ic -execdir 443primary is identical to the 444.Ic -exec 445primary with the exception that 446.Ar utility 447will be executed from the directory that holds 448the current file. 449The filename substituted for 450the string 451.Dq Li {} 452is not qualified. 453.It Ic -execdir Ar utility Oo Ar argument ... Oc Li {} + 454Same as 455.Ic -execdir , 456except that 457.Dq Li {} 458is replaced with as many pathnames as possible for each invocation of 459.Ar utility . 460This behaviour is similar to that of 461.Xr xargs 1 . 462The primary always returns true; 463if at least one invocation of 464.Ar utility 465returns a non-zero exit status, 466.Nm 467will return a non-zero exit status. 468.It Ic -executable 469Matches files which are executable by the current user. 470This test makes use of the 471.Xr access 2 472system call, and so can be fooled by NFS servers which do UID mapping (or root-squashing). 473This is a GNU find extension. 474.It Ic -flags Oo Cm - Ns | Ns Cm + Oc Ns Ar flags , Ns Ar notflags 475The flags are specified using symbolic names (see 476.Xr chflags 1 ) . 477Those with the 478.Qq Li no 479prefix (except 480.Qq Li nodump ) 481are said to be 482.Ar notflags . 483Flags in 484.Ar flags 485are checked to be set, and flags in 486.Ar notflags 487are checked to be not set. 488Note that this is different from 489.Ic -perm , 490which only allows the user to specify mode bits that are set. 491.Pp 492If flags are preceded by a dash 493.Pq Dq Li - , 494this primary evaluates to true 495if at least all of the bits in 496.Ar flags 497and none of the bits in 498.Ar notflags 499are set in the file's flags bits. 500If flags are preceded by a plus 501.Pq Dq Li + , 502this primary evaluates to true 503if any of the bits in 504.Ar flags 505is set in the file's flags bits, 506or any of the bits in 507.Ar notflags 508is not set in the file's flags bits. 509Otherwise, 510this primary evaluates to true 511if the bits in 512.Ar flags 513exactly match the file's flags bits, 514and none of the 515.Ar flags 516bits match those of 517.Ar notflags . 518.It Ic -fprint Ar filename 519This primary always evaluates to true. 520This creates 521.Ar filename 522or truncates the file if it already exists. 523The file is created at startup. 524It writes the pathname of the current file to this file, followed 525by a newline character. 526The file will be empty if no files are matched. 527.Pp 528.It Ic -fprint0 Ar filename 529This primary always evaluates to true. 530This creates 531.Ar filename 532or truncates the file if it already exists. 533The file is created at startup. 534It writes the pathname of the current file to this file, followed 535by an ASCII 536.Dv NUL 537character (character code 0). 538The file will be empty if no files are matched. 539.Pp 540.It Ic -fstype Ar type 541True if the file is contained in a file system of type 542.Ar type . 543The 544.Xr lsvfs 1 545command can be used to find out the types of file systems 546that are available on the system. 547In addition, there are two pseudo-types, 548.Dq Li local 549and 550.Dq Li rdonly . 551The former matches any file system physically mounted on the system where 552the 553.Nm 554is being executed and the latter matches any file system which is 555mounted read-only. 556.It Ic -gid Ar gname 557The same thing as 558.Ic -group Ar gname 559for compatibility with GNU find. 560GNU find imposes a restriction that 561.Ar gname 562is numeric, while 563.Nm 564does not. 565.It Ic -group Ar gname 566True if the file belongs to the group 567.Ar gname . 568If 569.Ar gname 570is numeric and there is no such group name, then 571.Ar gname 572is treated as a group ID. 573.It Ic -ignore_readdir_race 574Ignore errors because a file or a directory is deleted 575after reading the name from a directory. 576This option does not affect errors occurring on starting points. 577.It Ic -ilname Ar pattern 578Like 579.Ic -lname , 580but the match is case insensitive. 581This is a GNU find extension. 582.It Ic -iname Ar pattern 583Like 584.Ic -name , 585but the match is case insensitive. 586.It Ic -inum Ar n 587True if the file has inode number 588.Ar n . 589.It Ic -ipath Ar pattern 590Like 591.Ic -path , 592but the match is case insensitive. 593.It Ic -iregex Ar pattern 594Like 595.Ic -regex , 596but the match is case insensitive. 597.It Ic -iwholename Ar pattern 598The same thing as 599.Ic -ipath , 600for GNU find compatibility. 601.It Ic -links Ar n 602True if the file has 603.Ar n 604links. 605.It Ic -lname Ar pattern 606Like 607.Ic -name , 608but the contents of the symbolic link are matched instead of the file 609name. 610Note that this only matches broken symbolic links 611if symbolic links are being followed. 612This is a GNU find extension. 613.It Ic -ls 614This primary always evaluates to true. 615The following information for the current file is written to standard output: 616its inode number, size in 512-byte blocks, file permissions, number of hard 617links, owner, group, size in bytes, last modification time, and pathname. 618If the file is a block or character special file, the device number 619will be displayed instead of the size in bytes. 620If the file is a symbolic link, the pathname of the linked-to file will be 621displayed preceded by 622.Dq Li -> . 623The format is identical to that produced by 624.Bk -words 625.Dq Nm ls Fl dils . 626.Ek 627.It Ic -maxdepth Ar n 628Always true; descend at most 629.Ar n 630directory levels below the command line arguments. 631If any 632.Ic -maxdepth 633primary is specified, it applies to the entire expression even if it would 634not normally be evaluated. 635.Dq Ic -maxdepth Li 0 636limits the whole search to the command line arguments. 637.It Ic -mindepth Ar n 638Always true; do not apply any tests or actions at levels less than 639.Ar n . 640If any 641.Ic -mindepth 642primary is specified, it applies to the entire expression even if it would 643not normally be evaluated. 644.Dq Ic -mindepth Li 1 645processes all but the command line arguments. 646.It Ic -mmin Oo Cm - Ns | Ns Cm + Oc Ns Ar n 647True if the difference between the file last modification time and the time 648.Nm 649was started, rounded up to the next full minute, is 650more than 651.Ar n 652.Pq + Ns Ar n , 653less than 654.Ar n 655.Pq - Ns Ar n , 656or exactly 657.Ar n 658minutes ago. 659.It Ic -mnewer Ar file 660Same as 661.Ic -newer . 662.It Ic -mount 663The same thing as 664.Ic -xdev , 665for GNU find compatibility. 666.It Ic -mtime Ar n Ns Op Cm smhdw 667If no units are specified, this primary evaluates to 668true if the difference between the file last modification time and the time 669.Nm 670was started, rounded up to the next full 24-hour period, is 671.Ar n 67224-hour periods. 673.Pp 674If units are specified, this primary evaluates to 675true if the difference between the file last modification time and the time 676.Nm 677was started is exactly 678.Ar n 679units. 680Please refer to the 681.Ic -atime 682primary description for information on supported time units. 683.It Ic -name Ar pattern 684True if the last component of the pathname being examined matches 685.Ar pattern . 686Special shell pattern matching characters 687.Dq ( Li \&[ , 688.Dq Li \&] , 689.Dq Li * , 690and 691.Dq Li \&? ) 692may be used as part of 693.Ar pattern . 694These characters may be matched explicitly by escaping them with a 695backslash 696.Pq Dq Li \e . 697.It Ic -newer Ar file 698True if the current file has a more recent last modification time than 699.Ar file . 700.It Ic -newer Ns Ar X Ns Ar Y Ar file 701True if the current file has a more recent last access time 702.Pq Ar X Ns = Ns Cm a , 703inode creation time 704.Pq Ar X Ns = Ns Cm B , 705change time 706.Pq Ar X Ns = Ns Cm c , 707or modification time 708.Pq Ar X Ns = Ns Cm m 709than the last access time 710.Pq Ar Y Ns = Ns Cm a , 711inode creation time 712.Pq Ar Y Ns = Ns Cm B , 713change time 714.Pq Ar Y Ns = Ns Cm c , 715or modification time 716.Pq Ar Y Ns = Ns Cm m 717of 718.Ar file . 719In addition, if 720.Ar Y Ns = Ns Cm t , 721then 722.Ar file 723is instead interpreted as a direct date specification of the form 724understood by ISO8601 or RFC822. 725Note that 726.Ic -newermm 727is equivalent to 728.Ic -newer . 729.It Ic -nogroup 730True if the file belongs to an unknown group. 731.It Ic -noignore_readdir_race 732Turn off the effect of 733.Ic -ignore_readdir_race . 734This is default behaviour. 735.It Ic -noleaf 736This option is for GNU find compatibility. 737In GNU find it disables an optimization not relevant to 738.Nm , 739so it is ignored. 740.It Ic -nouser 741True if the file belongs to an unknown user. 742.It Ic -ok Ar utility Oo Ar argument ... Oc Li \&; 743The 744.Ic -ok 745primary is identical to the 746.Ic -exec 747primary with the exception that 748.Nm 749requests user affirmation for the execution of the 750.Ar utility 751by printing 752a message to the terminal and reading a response. 753If the response is not affirmative 754.Ql ( y 755in the 756.Dq Li POSIX 757locale), 758the command is not executed and the 759value of the 760.Ic -ok 761expression is false. 762.It Ic -okdir Ar utility Oo Ar argument ... Oc Li \&; 763The 764.Ic -okdir 765primary is identical to the 766.Ic -execdir 767primary with the same exception as described for the 768.Ic -ok 769primary. 770.It Ic -path Ar pattern 771True if the pathname being examined matches 772.Ar pattern . 773Special shell pattern matching characters 774.Dq ( Li \&[ , 775.Dq Li \&] , 776.Dq Li * , 777and 778.Dq Li \&? ) 779may be used as part of 780.Ar pattern . 781These characters may be matched explicitly by escaping them with a 782backslash 783.Pq Dq Li \e . 784Slashes 785.Pq Dq Li / 786are treated as normal characters and do not have to be 787matched explicitly. 788.It Ic -perm Oo Cm - Ns | Ns Cm + Ns | Ns Cm / Oc Ns Ar mode 789The 790.Ar mode 791may be either symbolic (see 792.Xr chmod 1 ) 793or an octal number. 794If the 795.Ar mode 796is symbolic, a starting value of zero is assumed and the 797.Ar mode 798sets or clears permissions without regard to the process' file mode 799creation mask. 800If the 801.Ar mode 802is octal, only bits 07777 803.Pq Dv S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO 804of the file's mode bits participate 805in the comparison. 806If the 807.Ar mode 808is preceded by a dash 809.Pq Dq Li - , 810this primary evaluates to true 811if at least all of the bits in the 812.Ar mode 813are set in the file's mode bits. 814If the 815.Ar mode 816is preceded by a plus 817.Pq Dq Li + 818this primary evaluates to true 819if any of the bits in the 820.Ar mode 821are set in the file's mode bits. 822A slash 823.Pq Dq Li / 824is also accepted with the same meaning as plus for compatibility with GNU find. 825Otherwise, this primary evaluates to true if 826the bits in the 827.Ar mode 828exactly match the file's mode bits. 829Note, the first character of a symbolic mode may not be a dash 830.Pq Dq Li - . 831.It Ic -print 832This primary always evaluates to true. 833It prints the pathname of the current file to standard output. 834If none of 835.Ic -exec , -ls , -print0 , 836or 837.Ic -ok 838is specified, the given expression shall be effectively replaced by 839.Cm \&( Ar "given expression" Cm \&) Ic -print . 840.It Ic -print0 841This primary always evaluates to true. 842It prints the pathname of the current file to standard output, followed by an 843ASCII 844.Dv NUL 845character (character code 0). 846.It Ic -printf Ar fmt 847This primary always evaluates to true. 848It prints information about the file, interpreting 849.Sq \ 850and 851.Sq % 852escape sequences as described in the PRINTF FORMATS section. 853Unlike 854.Ic -print , 855.Ic -printf 856does not add a newline automatically. 857.It Ic -prune 858This primary always evaluates to true. 859It causes 860.Nm 861to not descend into the current file. 862Note, the 863.Ic -prune 864primary has no effect if the 865.Fl d 866option was specified. 867.It Ic -quit 868Causes 869.Nm 870to terminate immediately. 871.It Ic -readable 872Matches files which are readable by the current user. 873This test makes use of the 874.Xr access 2 875system call, and so can be fooled by NFS servers which do UID mapping (or root-squashing). 876This is a GNU find extension. 877.It Ic -regex Ar pattern 878True if the whole path of the file matches 879.Ar pattern 880using regular expression. 881To match a file named 882.Dq Pa ./foo/xyzzy , 883you can use the regular expression 884.Dq Li ".*/[xyz]*" 885or 886.Dq Li ".*/foo/.*" , 887but not 888.Dq Li xyzzy 889or 890.Dq Li /foo/ . 891.It Ic -samefile Ar name 892True if the file is a hard link to 893.Ar name . 894If the command option 895.Ic -L 896is specified, it is also true if the file is a symbolic link and 897points to 898.Ar name . 899.It Ic -size Ar n Ns Op Cm ckMGTP 900True if the file's size, rounded up, in 512-byte blocks is 901.Ar n . 902If 903.Ar n 904is followed by a 905.Cm c , 906then the primary is true if the 907file's size is 908.Ar n 909bytes (characters). 910Similarly if 911.Ar n 912is followed by a scale indicator then the file's size is compared to 913.Ar n 914scaled as: 915.Pp 916.Bl -tag -width indent -compact 917.It Cm k 918kilobytes (1024 bytes) 919.It Cm M 920megabytes (1024 kilobytes) 921.It Cm G 922gigabytes (1024 megabytes) 923.It Cm T 924terabytes (1024 gigabytes) 925.It Cm P 926petabytes (1024 terabytes) 927.El 928.It Ic -sparse 929True if the current file is sparse, 930i.e. has fewer blocks allocated than expected based on its size in bytes. 931This might also match files that have been compressed by the filesystem. 932.It Ic -type Ar t 933True if the file is of the specified type. 934Possible file types are as follows: 935.Pp 936.Bl -tag -width indent -compact 937.It Cm b 938block special 939.It Cm c 940character special 941.It Cm d 942directory 943.It Cm f 944regular file 945.It Cm l 946symbolic link 947.It Cm p 948FIFO 949.It Cm s 950socket 951.El 952.It Ic -uid Ar uname 953The same thing as 954.Ar -user Ar uname 955for compatibility with GNU find. 956GNU find imposes a restriction that 957.Ar uname 958is numeric, while 959.Nm 960does not. 961.It Ic -user Ar uname 962True if the file belongs to the user 963.Ar uname . 964If 965.Ar uname 966is numeric and there is no such user name, then 967.Ar uname 968is treated as a user ID. 969.It Ic -wholename Ar pattern 970The same thing as 971.Ic -path , 972for GNU find compatibility. 973.It Ic -writable 974Matches files which are writable by the current user. 975This test makes use of the 976.Xr access 2 977system call, and so can be fooled by NFS servers which do UID mapping (or root-squashing). 978This is a GNU find extension. 979.It Ic -xattr 980Matches files which have extended attributes set in any supported namespace. 981.It Ic -xattrname Ar xattr 982Matches files which have the specified 983.Ar xattr 984extended attribute set. 985All supported namespaces are searched by default, but 986.Ar xattr 987may be prefixed with 988.Dq user: 989or 990.Dq system: 991to filter by namespace. 992.Pp 993Note that named attributes are not supported, only extended attributes as set 994by, e.g., 995.Xr setextattr 8 . 996.El 997.Sh OPERATORS 998The primaries may be combined using the following operators. 999The operators are listed in order of decreasing precedence. 1000.Pp 1001.Bl -tag -width indent -compact 1002.It Cm \&( Ar expression Cm \&) 1003This evaluates to true if the parenthesized expression evaluates to 1004true. 1005.Pp 1006.It Cm \&! Ar expression 1007.It Cm -not Ar expression 1008This is the unary 1009.Tn NOT 1010operator. 1011It evaluates to true if the expression is false. 1012.Pp 1013.It Cm -false 1014Always false. 1015.It Cm -true 1016Always true. 1017.Pp 1018.It Ar expression Cm -and Ar expression 1019.It Ar expression expression 1020The 1021.Cm -and 1022operator is the logical 1023.Tn AND 1024operator. 1025As it is implied by the juxtaposition of two expressions it does not 1026have to be specified. 1027The expression evaluates to true if both expressions are true. 1028The second expression is not evaluated if the first expression is false. 1029.Pp 1030.It Ar expression Cm -or Ar expression 1031The 1032.Cm -or 1033operator is the logical 1034.Tn OR 1035operator. 1036The expression evaluates to true if either the first or the second expression 1037is true. 1038The second expression is not evaluated if the first expression is true. 1039.El 1040.Pp 1041All operands and primaries must be separate arguments to 1042.Nm . 1043Primaries which themselves take arguments expect each argument 1044to be a separate argument to 1045.Nm . 1046.Sh PRINTF FORMATS 1047The following 1048.Sq \e 1049escapes are recognized: 1050.Bl -tag -width Ds -offset indent -compact 1051.It Cm \ea 1052Write a <bell> character. 1053.It Cm \eb 1054Write a <backspace> character. 1055.It Cm \ec 1056Writes no characters, but terminates the string and flushes the output so far 1057after each match. 1058.It Cm \ef 1059Write a <form-feed> character. 1060.It Cm \en 1061Write a <new-line> character. 1062.It Cm \er 1063Write a <carriage return> character. 1064.It Cm \et 1065Write a <tab> character. 1066.It Cm \ev 1067Write a <vertical tab> character. 1068.It Cm \e\' 1069Write a <single quote> character. 1070.It Cm \e\e 1071Write a backslash character. 1072.It Cm \e Ns Ar num 1073Write a byte whose 1074value is the 1-, 2-, or 3-digit 1075octal number 1076.Ar num . 1077Multibyte characters can be constructed using multiple 1078.Cm \e Ns Ar num 1079sequences. 1080.El 1081.Pp 1082Each format specification is introduced by the percent character 1083(``%''). 1084The remainder of the format specification includes, 1085in the following order: 1086.Bl -tag -width Ds 1087.It "Zero or more of the following flags:" 1088.Bl -tag -width Ds 1089.It Cm # 1090A `#' character, has no effect on almost all formats. 1091It is not yet implemented. 1092.It Cm \&\- 1093A minus sign `\-' which specifies 1094.Em left adjustment 1095of the output in the indicated field; 1096It is not yet implemented. 1097.It "Field Width:" 1098An optional digit string specifying a 1099.Em field width ; 1100if the output string has fewer bytes than the field width it will 1101be blank-padded on the left (or right, if the left-adjustment indicator 1102has been given) to make up the field width (note that a leading zero 1103is a flag, but an embedded zero is part of a field width); 1104It is not yet implemented. 1105.It Precision: 1106An optional period, 1107.Sq Cm \&.\& , 1108followed by an optional digit string giving a 1109.Em precision 1110which specifies the maximum number of bytes to be printed 1111from a string; if the digit string is missing, the precision is treated 1112as zero; 1113It is not yet implemented. 1114.It Format: 1115One or two characters, described below, which indicates the information to display. 1116.Bl -tag -width Ds 1117.It p 1118Path to file 1119.It f 1120Filename without directories. 1121.It h 1122Path relative to the starting point, or '.' if that's empty for some reason. 1123.It P 1124Unimplemented -- File with command line arg. 1125.It H 1126Unimplemented -- Command line arg. 1127.It g 1128gid in human readable form. 1129.It G 1130gid as a number. 1131.It h 1132uid in human readable form. 1133.It U 1134uid as a number. 1135.It m 1136File permission mode in octal. 1137.It M 1138File mode in 1139.Xr ls 1 1140standard form. 1141.It k 1142File size in KiB (units of 1024 bytes). 1143.It b 1144File size in blocks (Always 512 byte units, even if underlying storage 1145size differs). 1146.It s 1147Size in bytes of the file. 1148.It S 1149Sparseness of the file. 1150The blocks the file occupies times 512 divided by the file size. 1151.It d 1152Depth in the tree 1153.It D 1154Device number for the file. 1155.It F 1156Unimplemented -- Filesystem type where the file resides. 1157.It l 1158Object of the symbolic link. 1159.It i 1160Inode of the file. 1161.It n 1162Number of hard links. 1163.It y 1164A single character representing the type of the file. 1165.It Y 1166A single character representing the type of the file. 1167If the file is a symbolic link, show information for the target of the 1168link instead, or 1169.Sq L 1170if the link loops, 1171.Sq N 1172if the target does not exist, or 1173.Sq ? 1174if any other error occurs while attempting to determine the type of 1175the target. 1176.It a 1177Access time of the file. 1178.It A 1179Access time of the file in strftime format. 1180Takes an additional argument. 1181.It B 1182Birth time of the file in strftime format. 1183Takes an additional argument. 1184.It c 1185Creation time of the file. 1186.It C 1187Creation time of the file in strftime format. 1188Takes an additional argument. 1189.It t 1190Modification time of the file. 1191.It T 1192Modification time of the file in strftime format. 1193Takes an additional argument. 1194.El 1195Any format not listed is not supported, though the error changes. 1196.El 1197.El 1198.Sh ENVIRONMENT 1199The 1200.Ev LANG , LC_ALL , LC_COLLATE , LC_CTYPE , LC_MESSAGES 1201and 1202.Ev LC_TIME 1203environment variables affect the execution of the 1204.Nm 1205utility as described in 1206.Xr environ 7 . 1207.Sh EXAMPLES 1208The following examples are shown as given to the shell: 1209.Bl -tag -width indent 1210.It Li "find / \e! -name \*q*.c\*q -print" 1211Print out a list of all the files whose names do not end in 1212.Pa .c . 1213.It Li "find / -newer ttt -user wnj -print" 1214Print out a list of all the files owned by user 1215.Dq wnj 1216that are newer 1217than the file 1218.Pa ttt . 1219.It Li "find / \e! \e( -newer ttt -user wnj \e) -print" 1220Print out a list of all the files which are not both newer than 1221.Pa ttt 1222and owned by 1223.Dq wnj . 1224.It Li "find / \e( -newer ttt -or -user wnj \e) -print" 1225Print out a list of all the files that are either owned by 1226.Dq wnj 1227or that are newer than 1228.Pa ttt . 1229.It Li "find / -newerct '1 minute ago' -print" 1230Print out a list of all the files whose inode change time is more 1231recent than the current time minus one minute. 1232.It Li "find / -type f -exec echo {} \e;" 1233Use the 1234.Xr echo 1 1235command to print out a list of all the files. 1236.It Li "find -L /usr/ports/packages -type l -exec rm -- {} +" 1237Delete all broken symbolic links in 1238.Pa /usr/ports/packages . 1239.It Li "find /usr/src -name CVS -prune -o -depth +6 -print" 1240Find files and directories that are at least seven levels deep 1241in the working directory 1242.Pa /usr/src . 1243.It Li "find /usr/src -name CVS -prune -o -mindepth 7 -print" 1244Is not equivalent to the previous example, since 1245.Ic -prune 1246is not evaluated below level seven. 1247.El 1248.Sh COMPATIBILITY 1249The 1250.Ic -follow 1251primary is deprecated; the 1252.Fl L 1253option should be used instead. 1254See the 1255.Sx STANDARDS 1256section below for details. 1257.Sh SEE ALSO 1258.Xr chflags 1 , 1259.Xr chmod 1 , 1260.Xr locate 1 , 1261.Xr lsvfs 1 , 1262.Xr whereis 1 , 1263.Xr which 1 , 1264.Xr xargs 1 , 1265.Xr extattr 2 , 1266.Xr stat 2 , 1267.Xr acl 3 , 1268.Xr fts 3 , 1269.Xr getgrent 3 , 1270.Xr getpwent 3 , 1271.Xr strmode 3 , 1272.Xr ascii 7 , 1273.Xr re_format 7 , 1274.Xr symlink 7 , 1275.Xr setextattr 8 1276.Sh STANDARDS 1277The 1278.Nm 1279utility syntax is a superset of the syntax specified by the 1280.St -p1003.1-2001 1281standard. 1282.Pp 1283All the single character options except 1284.Fl H 1285and 1286.Fl L 1287as well as 1288.Ic -amin , -anewer , -cmin , -cnewer , -delete , -empty , -fstype , 1289.Ic -iname , -inum , -iregex , -ls , -maxdepth , -mindepth , -mmin , 1290.Ic -not , -path , -print0 , -regex , -sparse 1291and all of the 1292.Fl B* 1293birthtime related primaries are extensions to 1294.St -p1003.1-2001 . 1295.Pp 1296Historically, the 1297.Fl d , L 1298and 1299.Fl x 1300options were implemented using the primaries 1301.Ic -depth , -follow , 1302and 1303.Ic -xdev . 1304These primaries always evaluated to true. 1305As they were really global variables that took effect before the traversal 1306began, some legal expressions could have unexpected results. 1307An example is the expression 1308.Ic -print Cm -o Ic -depth . 1309As 1310.Ic -print 1311always evaluates to true, the standard order of evaluation 1312implies that 1313.Ic -depth 1314would never be evaluated. 1315This is not the case. 1316.Pp 1317The operator 1318.Cm -or 1319was implemented as 1320.Cm -o , 1321and the operator 1322.Cm -and 1323was implemented as 1324.Cm -a . 1325.Pp 1326Historic implementations of the 1327.Ic -exec 1328and 1329.Ic -ok 1330primaries did not replace the string 1331.Dq Li {} 1332in the utility name or the 1333utility arguments if it had preceding or following non-whitespace characters. 1334This version replaces it no matter where in the utility name or arguments 1335it appears. 1336.Pp 1337The 1338.Fl E 1339option was inspired by the equivalent 1340.Xr grep 1 1341and 1342.Xr sed 1 1343options. 1344.Pp 1345The 1346.Ic -perm 1347primary accepts a leading slash 1348.Pq Dq Li / 1349as an alias for a leading plus 1350.Pq Dq Li + 1351for its argument as an extension of 1352.St -p1003.1-2001 1353to be compatible with GNU find. 1354.Sh HISTORY 1355A simple 1356.Nm 1357command appeared in 1358.At v1 1359and was removed in 1360.At v3 . 1361It was rewritten for 1362.At v5 1363and was later enhanced for the Programmer's Workbench (PWB). 1364These changes were later incorporated in 1365.At v7 . 1366.Sh BUGS 1367The special characters used by 1368.Nm 1369are also special characters to many shell programs. 1370In particular, the characters 1371.Dq Li * , 1372.Dq Li \&[ , 1373.Dq Li \&] , 1374.Dq Li \&? , 1375.Dq Li \&( , 1376.Dq Li \&) , 1377.Dq Li \&! , 1378.Dq Li \e 1379and 1380.Dq Li \&; 1381may have to be escaped from the shell. 1382.Pp 1383As there is no delimiter separating options and file names or file 1384names and the 1385.Ar expression , 1386it is difficult to specify files named 1387.Pa -xdev 1388or 1389.Pa \&! . 1390These problems are handled by the 1391.Fl f 1392option and the 1393.Xr getopt 3 1394.Dq Fl Fl 1395construct. 1396.Pp 1397The 1398.Ic -delete 1399primary does not interact well with other options that cause the file system 1400tree traversal options to be changed. 1401.Pp 1402The 1403.Ic -mindepth 1404and 1405.Ic -maxdepth 1406primaries are actually global options (as documented above). 1407They should 1408probably be replaced by options which look like options. 1409