FIND(1) General Commands Manual FIND(1) find - find [-H] [-L] [-P] [-D debugopts] [-Olevel] [starting-point...] [expression] GNU find. GNU find starting-point ( ) expression () ( OPERATORS) ( and or) find . `.' ( ). find ( ) `Security Considerations' findutils Finding Files findutils. . -H -L -P . `-' `(' `!'. . . -print ( -print0 ). `' . find . `' -H -L -P -D -O . -- find : ( `-'). `-' find . (wildcards) `./' '/'. ( ) GNU -files0-from find. -P . . find . -L . find ( find ). -noleaf. -P -noleaf . -L find . -L (predicate) -type ( ). find ( -delete) . -L -lname -ilname ''. -H . find . . ( ). . -H ( -maxdepth 0 ). -H -L -P . -P -H -L. GNU find (stats) . . . . -P ( -H -L) . . find ( ) . -H -L -newer . -newerXY -anewer -cnewer. -follow -L ( -L -follow -follow ). -D debugopts find . . findutils. find -D help. exec -exec -execdir -ok -okdir opt -O. rates (predicate). search . stat stat lstat. find . tree . all ( help). help . -Olevel . find . . 0 1. 1 . ( -name -regex) . 2 -type -xtype (inode). Unix readdir() (stat) . -fstype FOO FOO ( `/etc/mtab') find -false. 3 . ( ) . . -o -a . . ( -type f -type c). . find . . ( 1) 4.3.x. findutils find . . -readable -empty . -empty -readable . -readable -empty . . expression (). . : . -empty . ( ) . -print . . . -depth find . . . -regextype . . -o ( OR ) -a ( AND ). -a. -print -prune -quit. -print -delete -exec -execdir -ok -okdir -fls -fprint -fprintf -ls -print -printf. -delete ( -depth). . . -daystart ( -amin -atime -cmin -ctime -mmin -mtime) 24 . . -follow -L . . -noleaf. -follow . -H -L -follow -newer -newer . -newerXY -anewer -cnewer. -type . -follow -lname -ilname ''. -regextype type -regex -iregex . -regextype help. Texinfo ( SEE ALSO) . find emacs. -warn -nowarn . find . -warn tty -nowarn . find. POSIXLY_CORRECT -warn . . . . 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. NUL . file find . find . find . -maxdepth 0 . : . file find . (seek) file find -quit . " " findutils . -help, --help find . -ignore_readdir_race find (stat) . find . . ( find ). find -ignore_readdir_race -delete : -delete . -maxdepth levels levels ( ) . -maxdepth 0 . -mindepth levels levels ( ). -mindepth 1 . -mount . -xdev find. -noignore_readdir_race -ignore_readdir_race. -noleaf 2 . Unix CD-ROM MS-DOS AFS. Unix : `.'. ( ) `..' . find (stat) 2 ( '' leaf ). . -version, --version find . -xdev . -newerXY -samefile . -H -L -P -follow . ( stat(2) ) find . n ( -amin -mtime -gid -inum -links -size -uid -used) +n n -n n n n . : -amin n n . -anewer . -H -L . -atime n n*24 . find ( 24 ) -atime +1 . -cmin n n . -cnewer . -H -L . -ctime n n*24 . -atime . -empty . -executable ( ) . (ACLs) -perm. access(2) NFS (UID mapping) (root-squashing) access(2) UID . access(2) . -false (false). -fstype . Unix Unix: ufs 4.2 4.3 nfs tmp mfs S51K S52K. -printf %F . -gid n (GID) n . -group _ _ ( ). -ilname -lname . -L -follow . -iname -name . `fo*` `F??` `Foo` `FOO` `foo` `fOo` . `*foo*` '.foobar'. -inum n (inode) n . -samefile . -ipath -path . -iregex -regex . -iwholename -ipath. -ipath. -links n n . -lname . (metacharacters) `/` `.` . -L -follow . -mmin n n . -mtime n n*24 . -atime . -name ( ) . (slash) `-name a/b` ( -path ). (`-name /`) "/" ( "/" "/"). - - POSIXLY_CORRECT -nowarn. -prune . Bash . fnmatch(3). . -newer . -H -L . -newerXY X Y . X Y : a B c (inode) m t X t. B . XY . -d date GNU. . . -nogroup (GID) . -nouser (UID) . -path . `/` `.` find . -path "./sr*sc" ./src/misc ( ). -prune . . . : find bar -path /foo/bar/myfile -print Find -path . -path ( ). -path find HP-UX POSIX 2008. -perm ( ). . `-perm g=w` 0020 ( ). `/` `-` `-perm -g=w` . . -perm - . . `u` `g` `o` . . -perm / . . `u` `g` `o` . . ( -perm -000). -perm + ( 2005). -perm / . -readable . -perm. access(2) NFS UID ( root-squashing) access(2) UID . -regex . . ./fubar3, `.*bar.` `.*b.*3` `f.*r3`. find Emacs -regextype. -samefile (inode) . -L . -size n[cwbkMG] n . : `b' 512 ( ) `c' `w' `k' (KiB 1024 ) `M' (MiB 1024 * 1024 = 1048576 ) `G' (GiB 1024 * 1024 * 1024 = 1073741824 ) st_size stat lstat ( stat) . ls -l. `%k` `%b` -printf (sparse files) . `b` 512 1024 -ls. + - n . . -size -1M -size -1048576c. 0 1,048,575 . -true (true) . -type c c: b ( ) c ( ) d p (FIFO) f l -L -follow . -L -xtype. s socket D () `,' ( ). -uid n n . -used n n . -user uname uname ( ). -wholename pattern -path. -path. -writable . -perm. access(2) NFS UID ( root-squashing) access(2) UID . -xtype c -type . : -H -P c -L c `l'. -xtype -type. ( ) -xtype -type. -context ( SELinux ) glob. -delete <<>> . find ( ). : find -delete find . -delete -depth . -depth -prune -delete -prune . find -print -delete . -depth . -delete . -ignore_readdir_race find -delete : -delete <<>>. -exec ; <<>> 0. find <<;>>. <<{}>> find. ( <<\>>) . -exec. . . -exec -execdir . -exec {} + -exec . xargs . <<{}>> <<+>> ( <<\>>) . . <<+>> find . find . -exec my-command ... {} + -quit my-command . -exec <<>>. -execdir ; -execdir {} + -exec find . -exec {} find . . -exec <<+>> -execdir . PATH <<.>> -execdir. PATH . <<+>> find . find . + ; -execdir {} + <<>> -execdir {} ; <<>> 0. -fls -ls -fprint. . . -fprint . find . /dev/stdout /dev/stderr . . . -fprint0 -print0 -fprint. . . -fprintf -printf -fprint. . . -ls ls -dils . 1 . POSIXLY_CORRECT 512 . . -ok ; -exec . . <<>> . /dev/null. -files0-from. . POSIXLY_CORRECT find. find . LC_CTYPE ( ) LC_COLLATE ( ). -okdir ; -execdir -ok. <<>> . /dev/null. -files0-from. -print . find -print0 -print. . -print0 ( -print). find. -0 xargs. -printf <<\>> <<%>>. C printf(3). %s %d . <<->> ( ). -print -printf . : \a . \b . \c . \f . \n . \r . \t . \v . \0 ASCII NUL. \\ (<<\>>). \NNN ASCII NNN (). <<\>> . %% . %a C ctime(3). %Ak k <<@>> C strftime(3). k. strftime(3) . strftime(3). @ 1 1970 00:00 . : H (00..23) I (01..12) k (0..23) l (1..12) M (00..59) p r 12 (hh:mm:ss [AP]M) S (00.00 .. 61.00). . T 24 (hh:mm:ss.xxxxxxxxxx) + <<+>> <<2004-04-28+22:22:05.0>>. . ( TZ). . X (H:M:S). . Z ( EDT) : a (Sun..Sat) A (Sunday..Saturday) b (Jan..Dec) B (January..December) c (Sat Nov 04 12:02:33 EST 1989). ctime(3) . d (01..31) D (mm/dd/yy) F (yyyy-mm-dd) h b j (001..366) m (01..12) U (00..53) w (0..6) W (00..53) x (mm/dd/yy) y (00..99) Y (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 (inode) ( ). %k 1 . %s/1024 . %l ( ). %m ( ). `' %m. # ( `%#m'). %M ( ls). findutils 4.2.5 . %n . %p . %P . %s . %S . (BLOCKSIZE*st_blocks / st_size). . 1.0 1.0. . BLOCKSIZE 512 . . st_blocks 1.0. %t C ctime(3). %Tk k %A. %u . %U . %y ( ls -l) U= ( ) %Y ( %y) : `L'= `N'= `?' . %Z ( SELinux ) . %{ %[ %( . `%' ( ). `%' . . %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 expr . . -not expr ! expr POSIX. expr1 expr2 -a expr2 expr1 . expr1 -a expr2 expr1 expr2. expr1 -and expr2 expr1 expr2 POSIX. expr1 -o expr2 expr2 expr1 . 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 . C ( `\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 %P . GNU ls. -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). findutils-4.2.2 ( `*' `?' `[]') `.' IEEE PASC 126 . findutils. -type . POSIX `b' `c' `d' `l' `p' `f' `s'. GNU find `D' (Door) . GNU find . -ok . `' `' LC_MESSAGES. POSIXLY_CORRECT () (). nl_langinfo(3) YESEXPR NOEXPR. POSIXLY_CORRECT find . -newer . (dereferenced). HISTORY . -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 (locale) . POSIXLY_CORRECT -ok. NLSPATH . PATH -exec -execdir -ok -okdir. POSIXLY_CORRECT -ls -fls. POSIXLY_CORRECT 512 . 1024 . ( -nowarn) POSIX stderr -ok . 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) . (race condition) find xargs . o proggy NUL : $ proggy | find -files0-from - -maxdepth 0 -type f -empty `-files0-from -` (pipe) -maxdepth 0 ( ). o file . $ find . -type f -exec file '{}' \; . . `-exec ... +` `-execdir ... +` . - o set-user-ID /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 ). (Pruning) - 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 -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 Programmer's Workbench Dick Haight. A Research UNIX Reader: Annotated Excerpts from the Programmer's Manual, 1971-1986 Doug McIlroy . GNU find Eric Decker David MacKenzie Jay Plett Tim Wood. find -print0 xargs -0 Dan Bernstein. findutils-4.2.2 ( `*' `?' `[]') `.' IEEE POSIX 126 . findutils-4.3.3 -perm /000 . findutils-4.3.3. findutils-4.3.11 -delete find . find . find -delete. -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 findutils-4.5.12 -perm /MODE. +MODE findutils-4.2.21 2005. find . -name afile -o -name bfile -print afile find . -name afile -o \( -name bfile -a -print \). -a -o -a. "paths must precede expression" $ 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 findutils : GNU Savannah: GNU findutils bug-findutils: (C) 1990-2024 . GPLv3+: 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 3 . . : . FIND(1)