FIND(1) General Commands Manual FIND(1) find - find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression] find GNU . GNU find (starting-point), (. ""), ( (false) (true) ); find . , ".". find , (, , ), " " find, Finding Files find. , , . -H, -L -P . , , "-", "(" "!". (expression), , . , . , -print ( , , -print 0 ). "" . find, . "" -H, -L, -P, -D -O , . -- , , - , find : , ( `-"). , path `-', find . , , , , , , , "./" , "/". , , , , GNU -files0-from find. -P . . find , , . -L . find , , , ( find , ). -noleaf. -P, -noleaf - . -L find , , . -L, -type , , ( ). , find (, -delete), . -L , -lname -il name false. -H , . find , . , , , . , ( , ). , , , . -H , , , (, , -maxdepth 0 ). -H, -L -P, ; , . , -P , -H -L. GNU find , . . , , , , , . , , . -P ( -H, -L), , , . , . find (, - - , ), . -H -L, , -newer, , , . -newerXY, -a newer -c newer. -follow , -L, , ( , -L , -follow, , -follow , , , , - ). -D debugopts ; , , find , . . find . find -D help. . exec , -exec, -exec dir, -ok -okdir. opt , ; -O. rates , , . search . stat stat lstat. find . tree . all ( help). help . -Olevel . find , ( ); . . 0 1. 1 , . , , (, -name -regex). 2 -type -xtype , , , . Unix readdir() , , . -fstype FOO FOO, ( `/etc/mtab') find, -false. 3 , . , "" (.. ) , "", , . , . -o , , , , , -a , , , , . , , , . (, , -type f , -type c). , . find, . , , , . (.. 1) 4.3.x. find find , . , , . , -readable -empty . -empty -readable, . -readable -empty, . . (expression) , . , , , . : (Tests) "" ( true ) "" (false), - . -empty, , , . (Actions) (, - ) true false, , . , -print . , . "" (true). , -depth find (, . .). , . "" (true). , -regextype , . . , , -o ( ) -a ( ). , , -a. -print , (true), , -prune -quit. , -print , -delete, -exec, -exec dir, -ok, -ok dir, -files, -print, -fprintf, -ls, -print -printf. -delete ( -depth). (true). , . -daystart ( -amin, -atime, -cmin, -time, -mmin -mtime) , 24 . , . -follow ( -L). . -noleaf. -follow , . -H -L, -follow ( ) -newer; , -newer, , . -newerXY, -anewer -cnewer. , -type , , . -follow , -lname -ilname "" (false). -regextype type , -regex -iregex, . , , -regextype help. Texinfo ( ) . , find , emacs. -warn, -nowarn (-warn) (-nowarn ) . , - , find . -warn, tty -nowarn . , , find. POSIXLY_CORRECT -warn, , , . "" (true). , . , , , . - , find , , . , , , -L. -d -depth, FreeBSD, NetBSD, macOS X OpenBSD. -depth . -delete -depth. -files0-from file file , . , , , find. . file . -files0-from - standard input ( ) , , . -ok -okdir , , , standard input . file - - ASCII NUL (0x00). NUL, .. , , . , file , find , , . , find , "path" . , , find , . -maxdepth 0. : , , . file find, . , file find, -quit , . "" , find , - find. -help, --help find . -ignore_readdir_race find , . , find , , . , . : , , - ( , find: , ). , find -ignore_readdir_race -delete , : , -delete "" (true). -maxdepth levels levels ( ). -maxdepth 0 . -mindepth levels levels ( ). -mindepth 1 , . -mount . -x dev, find. -noignore_readdir_race -ignore_readdir_race. -noleaf , , 2 , . , Unix, , CD-ROM MS-DOS, AFS. Unix 2 : ".". , ( ) "..", . find , , 2 , , , ( -"" ). , , . -version, --version find . -xdev . , -newerXY -same file, , . -H, -L -P, -follow, , . (, stat(2) ), find . (, -amin, -mtime, -gid, -inum, -links, -size, -uid -used) n : +n , n; -n n; n n. : -amin n , n . -anewer reference , reference. reference -H -L, , . -atime n , 24 . find , 24- , , , -atime +1, two () . -cmin n , n . -cnewer reference , reference. reference -H -L, , . -ctime n , 24 . -atime, , . -empty , . -executable , , ( ). , -perm . access(2) NFS, UID (, root). , access(2) UID, . , access(2), , , , . -false . -fstype type type. Unix; , Unix, : ufs, 4.2, 4.3, nfs, tmp, mfs, S51K, S52K. -printf %F, . -gid n , n. -group gname , gname ( ). -ilname pattern -lname, . -L -follow, false, . -iname pattern -name, . , "fo*" "F??" "Foo", "FOO", "foo", "fOo", "fOo" .. "*foo*" ".foobar". -inum n , n, , n n. -samefile. -ipath pattern -path, . -iregex pattern -regex, . -iwholename pattern -ipath. , -ipath. -links n , n . -lname pattern , pattern. "/" ".". -L -follow, false, . -mmin n , n . -mtime n , 24 . -atime, , . -name pattern (.. ) pattern. , pattern , "-name a/b" ( -path). pattern ("-name /"), "/" ( "/" "/"). , "-", , , POSIXLY_CORRECT -nowarn. , , , -prune ( ). - , , , Bash, . fnmatch(3). , . -newer reference , reference. reference -H -L, , . -newerXY reference , X , Y reference. X Y : a reference. B reference. c reference. m reference. t reference . ; , , X t. ; , B . XY, . -d GNU date. , - , . , , , . -nogroup . -nouser . -path pattern pattern. "/" "." ; , , find . -path "./sr*sc" ./src/misc ( ). , -prune . , , , . , . , : find bar -path /foo/bar/myfile -print find -path . , -path, , ( , , , ). -path find HP-UX POSIX 2008. -perm mode mode ( ). , , , , . , "-perm g=w" , 0020 ( , ). "/" "-", , "-perm -g=w", . . -perm -mode mode. . "u", "g" "o", . . -perm /mode mode. . "u", "g" "o", . . mode , ( , -perm -000). -perm +mode ( 2005 ). -perm /mode. -readable , . , -perm . access(2) NFS, UID (, root). , access(2) UID, . , access(2), , , , . -regex pattern pattern. , . , ./fubar 3 `.*bar.' `.*b.*3', `f.*r3'. , find, Emacs, -regextype. -samefile name , name. -L, . -size n[cwbkMG] , n . : "b" 512- ( , ); "c" ; "w" ; "k" (, , 1024 ); "M" (, , 1024 * 1024 = 1048576 ); "G" (, , 1024 * 1024 * 1024 = 1073741824 ). - st_size, lstat ( stat) , . , , ls -l. , "%k" "%b" -printf - . "b" 512- 1024-, -ls. "+" "-", , "" "", .. n . , . , -size -1M -size -1048576c. , 0 1 048 575 . -true . -type c c: b (); c ( ); d ; p (FIFO); l ; , -L -follow, . , -L, -xtype; s socket D (Solaris). , "," ( GNU). -uid n , n. -used n , n . -user uname uname ( ). -wholename pattern -path. , -path. -writable , . , -perm . access(2) NFS, UID (, root). , access(2) UID, . , access(2), , , , . -xtype c , -type, . : -H -P, true, c; -L, true, c "l". , -xtype , -type . ( , , ), -xtype , -type. -context pattern glob pattern (glob - ). . SELinux. -delete ; , true. , find ( find ). : , find , , -delete, find , . -delete -depth. , , -depth -prune . -delete -prune. find -print, -delete . , -depth . -delete , . -ignore_readdir_race, find -delete; , , , . -delete . -exec command ; command; 0, . find , , ";". "{}" , , , , , find. , , ( "\") , . -exec . . . -exec ; -execdir. -exec command {} + -exec , ; , . , xargs. "{}" , "+"; ( "\") , . . - "+" , find . find , , . -exec my-command ... {} + -quit my-command. -exec true (). -execdir command ; -execdir command {} + -exec, , , , find. -exec, {} , find . , . -exec, "+" -execdir , command , . , , PATH "."; , , , -execdir. PATH, . - "+" , find . find , , . , + ;. -execdir command {} + true, -execdir command {} ; true , command 0. -fls file (True). -ls, file -fprintf. , . , . -fprint file . file. file find, ; , . /dev/stdout /dev/stderr ; , . , . , , . -fprint0 file . -print 0, file -fprintf. , . , . -fprintf file format . -printf, file -fprintf. , . , . -ls . ls -dils . 1 , POSIXLY_CORRECT, 512- . , . -ok command ; -exec, . , . "" (false). , /dev/null. -files0-from. , , . , POSIXLY_CORRECT find. , find. LC_CTYPE ( ) LC_COLLATE ( ). -okdir command ; -execdir, , -ok. , false. , /dev/null. -files0-from. -print . . find , , , , -print0 -print. , . -print0 . , ( , -print). , find , . -0 xargs. -printf format . format , "\" "%". printf(3). , , %s, %d, , , . , "-" ( ). -print, -printf . : \a . \b . \c . \f . \n \r . \t . \v . \0 ASCII . \\ ("\"). \NNN , ASCII, NNN ( ). "\", , . %% . %a , C c time(3). %Ak , k, "@", C strftime(3). k. , strftime(3) . - strftime(3). @ . 1, 1970, 00:00 , . : H (00..23) I (01..12) ( 0,..,23); l ( 1,..,12); M (00..59) p (AM) (PM); r , 12 (:: [AP]M); S (00.00 ,.., 61.00); . , 24 (::.xxxxxxxxxx). + , "+", `2004-04-28+22:22:05.0'; GNU; ( TZ); . X (::); . (, EDT) , . : a (Sun,..,Sat). A (Sunday,..,Saturday). b (Jan,..,Dec). B (January,..,December). c (Sat Nov 04 12:02:33 EST 1989 1989); , ctime(3), . d (01..31). D (//). F (--). , b. j (001..366) m (01..12) U (00,..,53). w (0,..,6). W (00,..,53). x (//). (00..99) (1970,...,). %b , , 512- . , , %s/512, , . %Bk , , k, %A. , . %c , C ctime(3). %Ck , k, %A. %d ; 0 , . %D , ( st_dev struct stat), . %f ; ( ). / "/". . %F , ; -fstype. %g , . %G . %h ; (, ). ( ), %h ".". , ( /), %h . . %H , . %i ( ). %k , , 1 . , , %s/1024, , . %l ( , ). %m ( ). "" , Unix, , %m. , # (, "%#m"). %M ( , ls). find 4.2.5 . %n . %p . %P , , . %s . %S . ( *st_blocks / st_size). , , . 1,0, , , , 1,0. , , , . , , , 512 . , . , st_blocks, , 1,0. %t , C ctime(3). %Tk , k, %A. %u , . %U . %y ( ls -l), U= ( ). %Y (, %y), : "L"=, "N"=, "?" . %Z ( SELinux). %{ %[ %( . "%", , , ( , ). "%" "format" , . , , . %m %d #, 0 +, , . , , G, U, b, D, k n. "-", ( ) . , . -prune . , . -depth, -prune . -delete -depth, -prune -delete . , src/emacs , - : find . -path ./src/emacs -prune -o -print -quit ( , ). -prune, -prune , -quit find. . , -exec ... + -execdir ... +, . -quit , , . , "find /tmp/foo /tmp/bar -print -quit" "/tmp/foo". -quit - , , . , , : find / -name needle -print -quit : ( expr ) , . , "(...)", : "\(...\)". ! expr (True), expr (false). ("!") . -not expr , ! expr, POSIX. expr1 expr2 -a ( ); expr2 , expr1 "" (false). expr1 -a expr2 , expr1 expr2. expr1 -and expr2 , expr1 expr2, POSIX. expr1 -o expr2 ; expr2 , expr1 "" (true). expr1 -or expr2 , expr1 -o expr2, POSIX. expr1 , expr2 ; expr1 expr2. expr1 ; expr2. , . -fprintf . , -a, (, , ) , , -o. , find . -name afile -o -name bfile -print afile. find , . , , . , , "\0" "/". (, ). -, . -print0, -fprint0 , , , . -ls, -fls . , (, "\f", "\"). . ( -ls -fls 041 0176) . -printf, -fprintf , . . %D, %F, %g, %G, %H, %Y %y , . %a, %b, %c, %d, %i, %k, %m, %M, %n, %s, %t, %u %U , , . %f, %h, %l, %p %Pp . , ls GNU. , -ls -fls. , find, "\0" , , . LC_CTYPE , . -print, -fprint , -printf -fprintf. find , , -print0 -print. -ok -okdir . . POSIX POSIXLY_CORRECT. POSIX (IEEE Std 1003.1-2008, 2016 ) : -H . -L . -name , POSIX POSIX fnmatch(3). find-4.2.2 (, "*", "?" "[]") ".", IEEE PASC 126. , find. -type . POSIX "b", "c", "d", "l", "p", "f" "s". GNU find "D", , , . , GNU find , . -ok . "" ("yes") "" ("no" ), LC_MESSAGES. POSIXLY_CORRECT, () (). nl_langinfo(3), , YESEXPR NOEXPR. POSIXLY_CORRECT , find. -newer . , . , . "" . -perm . POSIXLY_CORRECT , (, +a+x), POSIX. : -atime, -ctime, -depth, -exec, -group, -links, -mtime, -nogroup, -nouser, -ok, -path, -print, -prune, -size, -user -xdev. POSIX "(", ")", "!" / (AND/OR) -a -o. , , .. , POSIX. GNU find. POSIX , find : find , , . find , , . GNU find . , , , , . , GNU find , . find , . , , - . -noleaf, , , . , -L -follow, find - . , , , find , stat() chdir() , . -d BSD, , POSIX, -depth. POSIXLY_CORRECT -regex -iregex, POSIX. LANG , . LC_ALL , . LC_COLLATE POSIX , , -name. GNU find fnmatch(3) LC_COLLATE . -ok; LC_MESSAGES , -ok, LC_COLLATE. LC_CTYPE , , -name, fnmatch(3) . , , -ok. LC_CTYPE , ; " ". LC_MESSAGES , . POSIXLY_CORRECT, , -ok. NLSPATH . PATH , , -exec, -execdir, -ok -okdir. POSIXLY_CORRECT , -ls -fls. POSIXLY_CORRECT, 512 . 1024 . ( -nowarn) , POSIX , , -ok, , (stderr), . POSIXLY_CORRECT , -perm +zzz , -perm /zzz, +zzz . POSIXLY_CORRECT, . POSIXLY_CORRECT, , -ok, , find. TZ , -printf -fprintf. : "find | xargs" o core /tmp . $ find /tmp -name core -type f -print | xargs /bin/rm -f . , - , . : "find -print0 | xargs -0" o core /tmp ; , , , , . $ find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f -name -type, stat(2) . . - , find , , , , xargs, . o , proggy , , : $ proggy | find -files0-from - -maxdepth 0 -type f -empty "-files0-from -" standard input, .. , -maxdepth 0 , , ( , ). o file . $ find . -type f -exec file '{}' \; , , . , . `-exec ... +` , , `-execdir ... +` . ( 2- ) o , /root/suid.txt, - /root/big.txt. $ find / \ \( -perm -4000 -fprintf /root/suid.txt '%#m %u %p\n' \) , \ \( -size +100M -fprintf /root/big.txt '%-10s %p\n' \) '\' , . o , . $ find $HOME -mtime 0 , 24 , . , -mtime 0 24 . o , , . $ find /sbin /usr/sbin -executable \! -readable -print o , , . $ find . -perm 664 , , (, - ), . o , , - (, ). $ find . -perm -664 , , , 0777. o , - ( , - ). $ find . -perm /222 o , . $ find . -perm /220 $ find . -perm /u+w,g+w $ find . -perm /u=w,g=w , , - . , , ; . o , , . $ find . -perm -220 $ find . -perm -g+w,u+w . o . $ find . -perm -444 -perm /222 \! -perm /111 $ find . -perm -a+r -perm /a+w \! -perm /a+x , (-perm -444 -perm -a+r), , (-perm /222 -perm /a+w), (! -perm /111 ! -perm /a+x, ). - o /source-dir /dest-dir, ( , ) .snapshot . , "~", . $ cd /source-dir $ find . -name .snapshot -prune -o \( \! -name '*~' -print0 \) \ | cpio -pmd0 /dest-dir -prune -o \( ... -print0 \) . , -prune , . -prune true, -o , , ( , ). -o . , -print0 , -prune. , , "and" (" ") , -o (" "), , , . o SCM, : $ find repo/ \ \( -exec test -d '{}/.svn' \; \ -or -exec test -d '{}/.git' \; \ -or -exec test -d '{}/CVS' \; \ \) -print -prune : repo/project1/CVS repo/gnu/project2/.svn repo/gnu/project3/.svn repo/gnu/project3/src/.svn repo/project4/.git -prune , (, project3/src, project3/.svn), (project2 project3). o . $ find /tmp -type f,d,l , /tmp, , ( GNU), , : $ find /tmp \( -type f -o -type d -o -type l \) o needle , . $ find / -name needle -print -quit o %f %h -printf . , . $ find . .. / /tmp /tmp/TRACE compile compile/64/tests/find -maxdepth 0 -printf '[%h][%f]\n' [.][.] [.][..] [][/] [][tmp] [/tmp][TRACE] [.][compile] [compile/64/tests][find] find 0, , 0, . , , find. - find , . , , -exec ... {} + -execdir ... {} +. find 5 Unix " " (Dick Haight). (Doug McIlroy) " UNIX: " ", 1971-1986" ; . GNU find (Eric Decker), (David MacKenzie), (Jay Plett) (Tim Wood). find -print0 xargs -0 (Dan Bernstein). find-4.2.2, (, "*", "?" "[]"), , ".", IEEE POSIX 126. find-4.3.3, -perm /000 , . find-4.3.3. find-4.3.11, -delete find . , find . -delete find. -files0-from 4.9.0 -newerXY 4.3.3 BSD -D 4.3.1 -O 4.3.1 -readable 4.3.0 -writable 4.3.0 -executable 4.3.0 -regextype 4.2.24 -exec ... + 4.2.12 POSIX -execdir 4.2.12 BSD -okdir 4.2.12 -samefile 4.2.11 -H 4.2.5 POSIX -L 4.2.5 POSIX -P 4.2.5 BSD -delete 4.2.3 -quit 4.2.3 -d 4.2.3 BSD -wholename 4.2.0 -iwholename 4.2.0 -ignore_readdir_race 4.2.0 -fls 4.0 -ilname 3.8 -iname 3.8 -ipath 3.8 -iregex 3.8 -perm +MODE find-4.5.12 -perm /MODE. +MODE find-4.2.21, 2005 . find . -name afile -o -name bfile -print afile, find . -name afile -o \( -name bfile -a -print \). , -a , -o , , -a. "paths expression" error message $ find . -name *.c -print find: paths must precede expression find: possible unquoted pattern after predicate `-name'? , *.c , find : find . -name frcode.c locate.c word_io.c -print , , , -name . , , , find , : $ find . -name '*.c' -print $ find . -name \*.c -print , POSIX find, , , , . , -exec -execdir. LC_COLLATE -ok. - GNU find: GNU Savannah: , GNU find, bug-findutils: (C) 1990-2024 Free Software Foundation, Inc. GPLv3+: GNU GPL 3 . : . , . chmod(1), locate(1), ls(1), updatedb(1), xargs(1), lstat(2), stat(2), ctime(3) fnmatch(3), printf(3), strftime(3), locatedb(5), regex(7) : info find () Aleksandr Felda Kirill Rekhov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () <>. FIND(1)