xref: /freebsd/usr.bin/find/find.1 (revision 56f7a84010f27e82abb3d22633c390587ec73972)
19b50d902SRodney W. Grimes.\" Copyright (c) 1990, 1993
29b50d902SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
39b50d902SRodney W. Grimes.\"
49b50d902SRodney W. Grimes.\" This code is derived from software contributed to Berkeley by
59b50d902SRodney W. Grimes.\" the Institute of Electrical and Electronics Engineers, Inc.
69b50d902SRodney W. Grimes.\"
79b50d902SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
89b50d902SRodney W. Grimes.\" modification, are permitted provided that the following conditions
99b50d902SRodney W. Grimes.\" are met:
109b50d902SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
119b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
129b50d902SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
139b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
149b50d902SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
159b50d902SRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software
169b50d902SRodney W. Grimes.\"    must display the following acknowledgement:
179b50d902SRodney W. Grimes.\"	This product includes software developed by the University of
189b50d902SRodney W. Grimes.\"	California, Berkeley and its contributors.
199b50d902SRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors
209b50d902SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
219b50d902SRodney W. Grimes.\"    without specific prior written permission.
229b50d902SRodney W. Grimes.\"
239b50d902SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
249b50d902SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
259b50d902SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
269b50d902SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
279b50d902SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
289b50d902SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
299b50d902SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
309b50d902SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
319b50d902SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
329b50d902SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
339b50d902SRodney W. Grimes.\" SUCH DAMAGE.
349b50d902SRodney W. Grimes.\"
35841484cdSPeter Wemm.\"	@(#)find.1	8.7 (Berkeley) 5/9/95
3656f7a840SBill Fumerola.\"	$Id: find.1,v 1.17 1998/11/29 12:00:06 bde Exp $
379b50d902SRodney W. Grimes.\"
38841484cdSPeter Wemm.Dd May 9, 1995
399b50d902SRodney W. Grimes.Dt FIND 1
409b50d902SRodney W. Grimes.Os
419b50d902SRodney W. Grimes.Sh NAME
429b50d902SRodney W. Grimes.Nm find
439b50d902SRodney W. Grimes.Nd walk a file hierarchy
449b50d902SRodney W. Grimes.Sh SYNOPSIS
459b50d902SRodney W. Grimes.Nm find
469b50d902SRodney W. Grimes.Op Fl H | Fl L | Fl P
476d0c7e13SWolfram Schneider.Op Fl Xdsx
489b50d902SRodney W. Grimes.Op Fl f Ar file
499b50d902SRodney W. Grimes.Op Ar file ...
509b50d902SRodney W. Grimes.Ar expression
519b50d902SRodney W. Grimes.Sh DESCRIPTION
529b50d902SRodney W. Grimes.Nm Find
539b50d902SRodney W. Grimesrecursively descends the directory tree for each
549b50d902SRodney W. Grimes.Ar file
559b50d902SRodney W. Grimeslisted, evaluating an
569b50d902SRodney W. Grimes.Ar expression
579b50d902SRodney W. Grimes(composed of the ``primaries'' and ``operands'' listed below) in terms
589b50d902SRodney W. Grimesof each file in the tree.
599b50d902SRodney W. Grimes.Pp
609b50d902SRodney W. GrimesThe options are as follows:
619b50d902SRodney W. Grimes.Pp
629b50d902SRodney W. Grimes.Bl -tag -width Ds
639b50d902SRodney W. Grimes.It Fl H
649b50d902SRodney W. GrimesThe
659b50d902SRodney W. Grimes.Fl H
669b50d902SRodney W. Grimesoption causes the file information and file type (see
679b50d902SRodney W. Grimes.Xr stat 2)
689b50d902SRodney W. Grimesreturned for each symbolic link specified on the command line to be
699b50d902SRodney W. Grimesthose of the file referenced by the link, not the link itself.
709b50d902SRodney W. GrimesIf the referenced file does not exist, the file information and type will
716df69548SBruce Evansbe for the link itself.
726df69548SBruce EvansFile information of all symbolic links not on
739b50d902SRodney W. Grimesthe command line is that of the link itself.
749b50d902SRodney W. Grimes.It Fl L
759b50d902SRodney W. GrimesThe
769b50d902SRodney W. Grimes.Fl L
779b50d902SRodney W. Grimesoption causes the file information and file type (see
789b50d902SRodney W. Grimes.Xr stat 2)
799b50d902SRodney W. Grimesreturned for each symbolic link to be those of the file referenced by the
809b50d902SRodney W. Grimeslink, not the link itself.
819b50d902SRodney W. GrimesIf the referenced file does not exist, the file information and type will
829b50d902SRodney W. Grimesbe for the link itself.
839b50d902SRodney W. Grimes.It Fl P
849b50d902SRodney W. GrimesThe
859b50d902SRodney W. Grimes.Fl P
869b50d902SRodney W. Grimesoption causes the file information and file type (see
879b50d902SRodney W. Grimes.Xr stat 2)
889b50d902SRodney W. Grimesreturned for each symbolic link to be those of the link itself.
893d9a9402SJohn PolstraThis is the default.
909b50d902SRodney W. Grimes.It Fl X
919b50d902SRodney W. GrimesThe
929b50d902SRodney W. Grimes.Fl X
939b50d902SRodney W. Grimesoption is a modification to permit
949b50d902SRodney W. Grimes.Nm
959b50d902SRodney W. Grimesto be safely used in conjunction with
969b50d902SRodney W. Grimes.Xr xargs 1 .
979b50d902SRodney W. GrimesIf a file name contains any of the delimiting characters used by
989b50d902SRodney W. Grimes.Xr xargs ,
999b50d902SRodney W. Grimesa diagnostic message is displayed on standard error, and the file
1009b50d902SRodney W. Grimesis skipped.
1019b50d902SRodney W. GrimesThe delimiting characters include single (`` ' '') and double (`` " '')
1029b50d902SRodney W. Grimesquotes, backslash (``\e''), space, tab and newline characters.
1039b50d902SRodney W. Grimes.It Fl d
1049b50d902SRodney W. GrimesThe
1059b50d902SRodney W. Grimes.Fl d
1069b50d902SRodney W. Grimesoption causes
1079b50d902SRodney W. Grimes.Nm find
1089b50d902SRodney W. Grimesto perform a depth\-first traversal, i.e. directories
1099b50d902SRodney W. Grimesare visited in post\-order and all entries in a directory will be acted
1109b50d902SRodney W. Grimeson before the directory itself.
1119b50d902SRodney W. GrimesBy default,
1129b50d902SRodney W. Grimes.Nm find
1139b50d902SRodney W. Grimesvisits directories in pre\-order, i.e. before their contents.
1149b50d902SRodney W. GrimesNote, the default is
1159b50d902SRodney W. Grimes.Ar not
1169b50d902SRodney W. Grimesa breadth\-first traversal.
1179b50d902SRodney W. Grimes.It Fl f
1189b50d902SRodney W. GrimesThe
1199b50d902SRodney W. Grimes.Fl f
1209b50d902SRodney W. Grimesoption specifies a file hierarchy for
1219b50d902SRodney W. Grimes.Nm find
1229b50d902SRodney W. Grimesto traverse.
1239b50d902SRodney W. GrimesFile hierarchies may also be specified as the operands immediately
1249b50d902SRodney W. Grimesfollowing the options.
1256d0c7e13SWolfram Schneider.It Fl s
1266d0c7e13SWolfram SchneiderThe
1276d0c7e13SWolfram Schneider.Fl s
1286df69548SBruce Evansoption causes
1296d0c7e13SWolfram Schneider.Nm find
1306df69548SBruce Evansto traverse the file hierarchies in lexicographical order,
1316df69548SBruce Evansi.e., alphabetical order within each directory.
1326df69548SBruce EvansNote:
1336d0c7e13SWolfram Schneider.Sq find -s
1346d0c7e13SWolfram Schneiderand
1356d0c7e13SWolfram Schneider.So
1366d0c7e13SWolfram Schneiderfind | sort
1376d0c7e13SWolfram Schneider.Sc
1386d0c7e13SWolfram Schneidermay give different results.
1399b50d902SRodney W. Grimes.It Fl x
1409b50d902SRodney W. GrimesThe
1419b50d902SRodney W. Grimes.Fl x
1429b50d902SRodney W. Grimesoption prevents
1439b50d902SRodney W. Grimes.Nm find
1449b50d902SRodney W. Grimesfrom descending into directories that have a device number different
1459b50d902SRodney W. Grimesthan that of the file from which the descent began.
1469b50d902SRodney W. Grimes.El
1479b50d902SRodney W. Grimes.Sh PRIMARIES
1489b50d902SRodney W. Grimes.Bl -tag -width Ds
1493f5223f8SWolfram Schneider.It Ic -amin Ar n
1503f5223f8SWolfram SchneiderTrue if the difference between the file last access time and the time
1513f5223f8SWolfram Schneider.Nm find
1523f5223f8SWolfram Schneiderwas started, rounded up to the next full minutes period, is
1533f5223f8SWolfram Schneider.Ar n
1543f5223f8SWolfram Schneiderminutes periods.
1559b50d902SRodney W. Grimes.It Ic -atime Ar n
1569b50d902SRodney W. GrimesTrue if the difference between the file last access time and the time
1579b50d902SRodney W. Grimes.Nm find
1589b50d902SRodney W. Grimeswas started, rounded up to the next full 24\-hour period, is
1599b50d902SRodney W. Grimes.Ar n
1609b50d902SRodney W. Grimes24\-hour periods.
1613f5223f8SWolfram Schneider.It Ic -cmin Ar n
1623f5223f8SWolfram SchneiderTrue if the difference between the time of last change of file status
1633f5223f8SWolfram Schneiderinformation and the time
1643f5223f8SWolfram Schneider.Nm find
1653f5223f8SWolfram Schneiderwas started, rounded up to the next full minutes period, is
1663f5223f8SWolfram Schneider.Ar n
1673f5223f8SWolfram Schneiderminutes periods.
1689b50d902SRodney W. Grimes.It Ic -ctime Ar n
1699b50d902SRodney W. GrimesTrue if the difference between the time of last change of file status
1709b50d902SRodney W. Grimesinformation and the time
1719b50d902SRodney W. Grimes.Nm find
1729b50d902SRodney W. Grimeswas started, rounded up to the next full 24\-hour period, is
1739b50d902SRodney W. Grimes.Ar n
1749b50d902SRodney W. Grimes24\-hour periods.
175abacbbbfSPeter Wemm.It Ic -delete
1766df69548SBruce EvansDelete found files and/or directories.
1776df69548SBruce EvansAlways returns true.
1786df69548SBruce EvansThis executes
179abacbbbfSPeter Wemmfrom the current working directory as
180abacbbbfSPeter Wemm.Nm
1816df69548SBruce Evansrecurses down the tree.
1826df69548SBruce EvansIt will not attempt to delete a filename with a ``/''
1836ad98044SEivind Eklundcharacter in its pathname relative to "." for security reasons.
184abacbbbfSPeter WemmDepth\-first traversal processing is implied by this option.
1859b50d902SRodney W. Grimes.It Ic -exec Ar utility Op argument ... ;
1869b50d902SRodney W. GrimesTrue if the program named
1879b50d902SRodney W. Grimes.Ar utility
1889b50d902SRodney W. Grimesreturns a zero value as its exit status.
1899b50d902SRodney W. GrimesOptional arguments may be passed to the utility.
1909b50d902SRodney W. GrimesThe expression must be terminated by a semicolon (``;'').
1919b50d902SRodney W. GrimesIf the string ``{}'' appears anywhere in the utility name or the
1929b50d902SRodney W. Grimesarguments it is replaced by the pathname of the current file.
1939b50d902SRodney W. Grimes.Ar Utility
1949b50d902SRodney W. Grimeswill be executed from the directory from which
1959b50d902SRodney W. Grimes.Nm find
1969b50d902SRodney W. Grimeswas executed.
197127d7563SWarner Losh.It Ic -execdir Ar utility Op argument ... ;
198127d7563SWarner LoshThe
199127d7563SWarner Losh.Ic \&-execdir
200127d7563SWarner Loshprimary is identical to the
201127d7563SWarner Losh.Ic -exec
202127d7563SWarner Loshprimary with the exception that
203127d7563SWarner Losh.Ar Utility
204127d7563SWarner Loshwill be executed from the directory that holds
2056df69548SBruce Evansthe current file.
2066df69548SBruce EvansThe filename substituted for
207127d7563SWarner Loshthe string ``{}'' is not qualified.
2089b50d902SRodney W. Grimes.It Ic -fstype Ar type
2099b50d902SRodney W. GrimesTrue if the file is contained in a file system of type
2109b50d902SRodney W. Grimes.Ar type .
211841484cdSPeter WemmThe
212841484cdSPeter Wemm.Xr sysctl 8
213841484cdSPeter Wemmcommand can be used to find out the types of filesystems
214841484cdSPeter Wemmthat are available on the system:
215841484cdSPeter Wemm.Bd -literal -offset indent
216841484cdSPeter Wemmsysctl vfs
217841484cdSPeter Wemm.Ed
218841484cdSPeter WemmIn addition, there are two pseudo-types, ``local'' and ``rdonly''.
2199b50d902SRodney W. GrimesThe former matches any file system physically mounted on the system where
2209b50d902SRodney W. Grimesthe
2219b50d902SRodney W. Grimes.Nm find
2229b50d902SRodney W. Grimesis being executed and the latter matches any file system which is
2239b50d902SRodney W. Grimesmounted read-only.
2249b50d902SRodney W. Grimes.It Ic -group Ar gname
2259b50d902SRodney W. GrimesTrue if the file belongs to the group
2269b50d902SRodney W. Grimes.Ar gname  .
2279b50d902SRodney W. GrimesIf
2289b50d902SRodney W. Grimes.Ar gname
2299b50d902SRodney W. Grimesis numeric and there is no such group name, then
2309b50d902SRodney W. Grimes.Ar gname
2319b50d902SRodney W. Grimesis treated as a group id.
2329b50d902SRodney W. Grimes.It Ic -inum Ar n
2339b50d902SRodney W. GrimesTrue if the file has inode number
2349b50d902SRodney W. Grimes.Ar n  .
2359b50d902SRodney W. Grimes.It Ic -links Ar n
2369b50d902SRodney W. GrimesTrue if the file has
2379b50d902SRodney W. Grimes.Ar n
2389b50d902SRodney W. Grimeslinks.
2399b50d902SRodney W. Grimes.It Ic -ls
2409b50d902SRodney W. GrimesThis primary always evaluates to true.
2419b50d902SRodney W. GrimesThe following information for the current file is written to standard output:
2429b50d902SRodney W. Grimesits inode number, size in 512\-byte blocks, file permissions, number of hard
2439b50d902SRodney W. Grimeslinks, owner, group, size in bytes, last modification time, and pathname.
2449b50d902SRodney W. GrimesIf the file is a block or character special file, the major and minor numbers
2459b50d902SRodney W. Grimeswill be displayed instead of the size in bytes.
2469b50d902SRodney W. GrimesIf the file is a symbolic link, the pathname of the linked\-to file will be
2479b50d902SRodney W. Grimesdisplayed preceded by ``\->''.
2489b50d902SRodney W. GrimesThe format is identical to that produced by ``ls \-dgils''.
2493f5223f8SWolfram Schneider.It Ic -mmin Ar n
2503f5223f8SWolfram SchneiderTrue if the difference between the file last modification time and the time
2513f5223f8SWolfram Schneider.Nm find
2523f5223f8SWolfram Schneiderwas started, rounded up to the next full minutes period, is
2533f5223f8SWolfram Schneider.Ar n
2543f5223f8SWolfram Schneiderminutes periods.
2559b50d902SRodney W. Grimes.It Ic -mtime Ar n
2569b50d902SRodney W. GrimesTrue if the difference between the file last modification time and the time
2579b50d902SRodney W. Grimes.Nm find
2589b50d902SRodney W. Grimeswas started, rounded up to the next full 24\-hour period, is
2599b50d902SRodney W. Grimes.Ar n
2609b50d902SRodney W. Grimes24\-hour periods.
261841484cdSPeter Wemm.It Ic \&-ok Ar utility Op argument ... ;
2629b50d902SRodney W. GrimesThe
2639b50d902SRodney W. Grimes.Ic \&-ok
2649b50d902SRodney W. Grimesprimary is identical to the
2659b50d902SRodney W. Grimes.Ic -exec
2669b50d902SRodney W. Grimesprimary with the exception that
2679b50d902SRodney W. Grimes.Nm find
2689b50d902SRodney W. Grimesrequests user affirmation for the execution of the utility by printing
2699b50d902SRodney W. Grimesa message to the terminal and reading a response.
2709b50d902SRodney W. GrimesIf the response is other than ``y'' the command is not executed and the
2719b50d902SRodney W. Grimesvalue of the
2729b50d902SRodney W. Grimes.Ar \&ok
2739b50d902SRodney W. Grimesexpression is false.
2749b50d902SRodney W. Grimes.It Ic -name Ar pattern
2759b50d902SRodney W. GrimesTrue if the last component of the pathname being examined matches
2769b50d902SRodney W. Grimes.Ar pattern  .
2779b50d902SRodney W. GrimesSpecial shell pattern matching characters (``['', ``]'', ``*'', and ``?'')
2789b50d902SRodney W. Grimesmay be used as part of
2799b50d902SRodney W. Grimes.Ar pattern  .
2809b50d902SRodney W. GrimesThese characters may be matched explicitly by escaping them with a
2819b50d902SRodney W. Grimesbackslash (``\e'').
2829b50d902SRodney W. Grimes.It Ic -newer Ar file
2839b50d902SRodney W. GrimesTrue if the current file has a more recent last modification time than
2849b50d902SRodney W. Grimes.Ar file  .
2859b50d902SRodney W. Grimes.It Ic -nouser
2869b50d902SRodney W. GrimesTrue if the file belongs to an unknown user.
2879b50d902SRodney W. Grimes.It Ic -nogroup
2889b50d902SRodney W. GrimesTrue if the file belongs to an unknown group.
2899b50d902SRodney W. Grimes.It Ic -path Ar pattern
2909b50d902SRodney W. GrimesTrue if the pathname being examined matches
2919b50d902SRodney W. Grimes.Ar pattern  .
2929b50d902SRodney W. GrimesSpecial shell pattern matching characters (``['', ``]'', ``*'', and ``?'')
2939b50d902SRodney W. Grimesmay be used as part of
2949b50d902SRodney W. Grimes.Ar pattern  .
2959b50d902SRodney W. GrimesThese characters may be matched explicitly by escaping them with a
2969b50d902SRodney W. Grimesbackslash (``\e'').
2979b50d902SRodney W. GrimesSlashes (``/'') are treated as normal characters and do not have to be
2989b50d902SRodney W. Grimesmatched explicitly.
2999b50d902SRodney W. Grimes.It Ic -perm Op Fl Ns Ar mode
3009b50d902SRodney W. GrimesThe
3019b50d902SRodney W. Grimes.Ar mode
3029b50d902SRodney W. Grimesmay be either symbolic (see
3039b50d902SRodney W. Grimes.Xr chmod  1  )
3049b50d902SRodney W. Grimesor an octal number.
3059b50d902SRodney W. GrimesIf the mode is symbolic, a starting value of zero is assumed and the
3069b50d902SRodney W. Grimesmode sets or clears permissions without regard to the process' file mode
3079b50d902SRodney W. Grimescreation mask.
3089b50d902SRodney W. GrimesIf the mode is octal, only bits 07777
3099b50d902SRodney W. Grimes.Pf ( Dv S_ISUID
3109b50d902SRodney W. Grimes|
3119b50d902SRodney W. Grimes.Dv S_ISGID
3129b50d902SRodney W. Grimes|
3139b50d902SRodney W. Grimes.Dv S_ISTXT
3149b50d902SRodney W. Grimes|
3159b50d902SRodney W. Grimes.Dv S_IRWXU
3169b50d902SRodney W. Grimes|
3179b50d902SRodney W. Grimes.Dv S_IRWXG
3189b50d902SRodney W. Grimes|
3199b50d902SRodney W. Grimes.Dv S_IRWXO )
3209b50d902SRodney W. Grimesof the file's mode bits participate
3219b50d902SRodney W. Grimesin the comparison.
3229b50d902SRodney W. GrimesIf the mode is preceded by a dash (``\-''), this primary evaluates to true
3239b50d902SRodney W. Grimesif at least all of the bits in the mode are set in the file's mode bits.
3249b50d902SRodney W. GrimesIf the mode is not preceded by a dash, this primary evaluates to true if
3259b50d902SRodney W. Grimesthe bits in the mode exactly match the file's mode bits.
3269b50d902SRodney W. GrimesNote, the first character of a symbolic mode may not be a dash (``\-'').
3279b50d902SRodney W. Grimes.It Ic -print
3289b50d902SRodney W. GrimesThis primary always evaluates to true.
3299b50d902SRodney W. GrimesIt prints the pathname of the current file to standard output.
330841484cdSPeter WemmIf none of
3319b50d902SRodney W. Grimes.Ic -exec ,
3327cd23434SGarrett Wollman.Ic -ls ,
3337cd23434SGarrett Wollman.Ic -print0 ,
3349b50d902SRodney W. Grimesor
3359b50d902SRodney W. Grimes.Ic \&-ok
336841484cdSPeter Wemmis specified, the given expression shall be effectively replaced by
337841484cdSPeter Wemm.Cm \&( Ns Ar given\& expression Ns Cm \&)
338841484cdSPeter Wemm.Ic -print .
3397cd23434SGarrett Wollman.It Ic -print0
3407cd23434SGarrett WollmanThis primary always evaluates to true.
341fbe0d04aSMasafumi Max NAKANEIt prints the pathname of the current file to standard output, followed by an
3427cd23434SGarrett Wollman.Tn ASCII
3437cd23434SGarrett Wollman.Tn NUL
3447cd23434SGarrett Wollmancharacter (character code 0).
3459b50d902SRodney W. Grimes.It Ic -prune
3469b50d902SRodney W. GrimesThis primary always evaluates to true.
3479b50d902SRodney W. GrimesIt causes
3489b50d902SRodney W. Grimes.Nm find
3499b50d902SRodney W. Grimesto not descend into the current file.
3509b50d902SRodney W. GrimesNote, the
3519b50d902SRodney W. Grimes.Ic -prune
3529b50d902SRodney W. Grimesprimary has no effect if the
3539b50d902SRodney W. Grimes.Fl d
3549b50d902SRodney W. Grimesoption was specified.
3559b50d902SRodney W. Grimes.It Ic -size Ar n Ns Op Cm c
3569b50d902SRodney W. GrimesTrue if the file's size, rounded up, in 512\-byte blocks is
3579b50d902SRodney W. Grimes.Ar n  .
3589b50d902SRodney W. GrimesIf
3599b50d902SRodney W. Grimes.Ar n
3609b50d902SRodney W. Grimesis followed by a ``c'', then the primary is true if the
3619b50d902SRodney W. Grimesfile's size is
3629b50d902SRodney W. Grimes.Ar n
3639b50d902SRodney W. Grimesbytes.
3649b50d902SRodney W. Grimes.It Ic -type Ar t
3659b50d902SRodney W. GrimesTrue if the file is of the specified type.
3669b50d902SRodney W. GrimesPossible file types are as follows:
3679b50d902SRodney W. Grimes.Pp
3689b50d902SRodney W. Grimes.Bl -tag -width flag -offset indent -compact
3699b50d902SRodney W. Grimes.It Cm b
3709b50d902SRodney W. Grimesblock special
3719b50d902SRodney W. Grimes.It Cm c
3729b50d902SRodney W. Grimescharacter special
3739b50d902SRodney W. Grimes.It Cm d
3749b50d902SRodney W. Grimesdirectory
3759b50d902SRodney W. Grimes.It Cm f
3769b50d902SRodney W. Grimesregular file
3779b50d902SRodney W. Grimes.It Cm l
3789b50d902SRodney W. Grimessymbolic link
3799b50d902SRodney W. Grimes.It Cm p
3809b50d902SRodney W. GrimesFIFO
3819b50d902SRodney W. Grimes.It Cm s
3829b50d902SRodney W. Grimessocket
3839b50d902SRodney W. Grimes.El
3849b50d902SRodney W. Grimes.Pp
3859b50d902SRodney W. Grimes.It Ic -user Ar uname
3869b50d902SRodney W. GrimesTrue if the file belongs to the user
3879b50d902SRodney W. Grimes.Ar uname  .
3889b50d902SRodney W. GrimesIf
3899b50d902SRodney W. Grimes.Ar uname
3909b50d902SRodney W. Grimesis numeric and there is no such user name, then
3919b50d902SRodney W. Grimes.Ar uname
3929b50d902SRodney W. Grimesis treated as a user id.
3939b50d902SRodney W. Grimes.El
3949b50d902SRodney W. Grimes.Pp
3959b50d902SRodney W. GrimesAll primaries which take a numeric argument allow the number to be
3969b50d902SRodney W. Grimespreceded by a plus sign (``+'') or a minus sign (``\-'').
3979b50d902SRodney W. GrimesA preceding plus sign means ``more than n'', a preceding minus sign means
3989b50d902SRodney W. Grimes``less than n'' and neither means ``exactly n'' .
3999b50d902SRodney W. Grimes.Sh OPERATORS
4009b50d902SRodney W. GrimesThe primaries may be combined using the following operators.
4019b50d902SRodney W. GrimesThe operators are listed in order of decreasing precedence.
4029b50d902SRodney W. Grimes.Bl -tag -width (expression)
4039b50d902SRodney W. Grimes.It Cm \&( Ns Ar expression Ns Cm \&)
4049b50d902SRodney W. GrimesThis evaluates to true if the parenthesized expression evaluates to
4059b50d902SRodney W. Grimestrue.
4069b50d902SRodney W. Grimes.Pp
4079b50d902SRodney W. Grimes.It Cm \&! Ns Ar expression
4089b50d902SRodney W. GrimesThis is the unary
4099b50d902SRodney W. Grimes.Tn NOT
4109b50d902SRodney W. Grimesoperator.
4119b50d902SRodney W. GrimesIt evaluates to true if the expression is false.
4129b50d902SRodney W. Grimes.Pp
4139b50d902SRodney W. Grimes.It Ar expression Cm -and Ar expression
4149b50d902SRodney W. Grimes.It Ar expression expression
4159b50d902SRodney W. GrimesThe
4169b50d902SRodney W. Grimes.Cm -and
4179b50d902SRodney W. Grimesoperator is the logical
4189b50d902SRodney W. Grimes.Tn AND
4199b50d902SRodney W. Grimesoperator.
4209b50d902SRodney W. GrimesAs it is implied by the juxtaposition of two expressions it does not
4219b50d902SRodney W. Grimeshave to be specified.
4229b50d902SRodney W. GrimesThe expression evaluates to true if both expressions are true.
4239b50d902SRodney W. GrimesThe second expression is not evaluated if the first expression is false.
4249b50d902SRodney W. Grimes.Pp
4259b50d902SRodney W. Grimes.It Ar expression Cm -or Ar expression
4269b50d902SRodney W. GrimesThe
4279b50d902SRodney W. Grimes.Cm -or
4289b50d902SRodney W. Grimesoperator is the logical
4299b50d902SRodney W. Grimes.Tn OR
4309b50d902SRodney W. Grimesoperator.
4319b50d902SRodney W. GrimesThe expression evaluates to true if either the first or the second expression
4329b50d902SRodney W. Grimesis true.
4339b50d902SRodney W. GrimesThe second expression is not evaluated if the first expression is true.
4349b50d902SRodney W. Grimes.El
4359b50d902SRodney W. Grimes.Pp
4369b50d902SRodney W. GrimesAll operands and primaries must be separate arguments to
4379b50d902SRodney W. Grimes.Nm find  .
4389b50d902SRodney W. GrimesPrimaries which themselves take arguments expect each argument
4399b50d902SRodney W. Grimesto be a separate argument to
4409b50d902SRodney W. Grimes.Nm find  .
4419b50d902SRodney W. Grimes.Sh EXAMPLES
4429b50d902SRodney W. Grimes.Pp
4439b50d902SRodney W. GrimesThe following examples are shown as given to the shell:
4449b50d902SRodney W. Grimes.Bl -tag -width findx
4459b50d902SRodney W. Grimes.It Li "find  /  \e!  -name  \*q*.c\*q  -print"
4469b50d902SRodney W. GrimesPrint out a list of all the files whose names do not end in ``.c''.
4479b50d902SRodney W. Grimes.It Li "find  /  -newer  ttt  -user  wnj  -print"
4489b50d902SRodney W. GrimesPrint out a list of all the files owned by user ``wnj'' that are newer
4499b50d902SRodney W. Grimesthan the file ``ttt''.
4509b50d902SRodney W. Grimes.It Li "find  /  \e!  \e(  -newer  ttt  -user  wnj  \e)  -print"
4519b50d902SRodney W. GrimesPrint out a list of all the files which are not both newer than ``ttt''
4529b50d902SRodney W. Grimesand owned by ``wnj''.
4539b50d902SRodney W. Grimes.It Li "find  /  \e(  -newer  ttt  -or  -user wnj  \e)  -print"
4549b50d902SRodney W. GrimesPrint out a list of all the files that are either owned by ``wnj'' or
4559b50d902SRodney W. Grimesthat are newer than ``ttt''.
4569b50d902SRodney W. Grimes.El
4579b50d902SRodney W. Grimes.Sh SEE ALSO
4589b50d902SRodney W. Grimes.Xr chmod 1 ,
4599b50d902SRodney W. Grimes.Xr locate 1 ,
46041cbb624SJoseph Koshy.Xr whereis 1 ,
46141cbb624SJoseph Koshy.Xr which 1 ,
4629b50d902SRodney W. Grimes.Xr stat 2 ,
4639b50d902SRodney W. Grimes.Xr fts 3 ,
4649b50d902SRodney W. Grimes.Xr getgrent 3 ,
4659b50d902SRodney W. Grimes.Xr getpwent 3 ,
4669b50d902SRodney W. Grimes.Xr strmode 3 ,
4679b50d902SRodney W. Grimes.Xr symlink 7
4689b50d902SRodney W. Grimes.Sh STANDARDS
4699b50d902SRodney W. GrimesThe
4709b50d902SRodney W. Grimes.Nm find
4719b50d902SRodney W. Grimesutility syntax is a superset of the syntax specified by the
4729b50d902SRodney W. Grimes.St -p1003.2
4739b50d902SRodney W. Grimesstandard.
4749b50d902SRodney W. Grimes.Pp
475f6e4fb22SSteve PriceAll the single character options as well as the
476f6e4fb22SSteve Price.Ic -inum ,
477f6e4fb22SSteve Price.Ic -print0 ,
478f6e4fb22SSteve Price.Ic -delete ,
479f6e4fb22SSteve Priceand
480f6e4fb22SSteve Price.Ic -ls
481f6e4fb22SSteve Priceprimaries are extensions to
482f6e4fb22SSteve Price.St -p1003.2 .
483f6e4fb22SSteve Price.Pp
4849b50d902SRodney W. GrimesHistorically, the
4859b50d902SRodney W. Grimes.Fl d ,
4869b50d902SRodney W. Grimes.Fl h
4879b50d902SRodney W. Grimesand
4889b50d902SRodney W. Grimes.Fl x
4899b50d902SRodney W. Grimesoptions were implemented using the primaries ``\-depth'', ``\-follow'',
4909b50d902SRodney W. Grimesand ``\-xdev''.
4919b50d902SRodney W. GrimesThese primaries always evaluated to true.
4929b50d902SRodney W. GrimesAs they were really global variables that took effect before the traversal
4939b50d902SRodney W. Grimesbegan, some legal expressions could have unexpected results.
4949b50d902SRodney W. GrimesAn example is the expression ``\-print \-o \-depth''.
4959b50d902SRodney W. GrimesAs \-print always evaluates to true, the standard order of evaluation
4969b50d902SRodney W. Grimesimplies that \-depth would never be evaluated.
4979b50d902SRodney W. GrimesThis is not the case.
4989b50d902SRodney W. Grimes.Pp
4999b50d902SRodney W. GrimesThe operator ``-or'' was implemented as ``\-o'', and the operator ``-and''
5009b50d902SRodney W. Grimeswas implemented as ``\-a''.
5019b50d902SRodney W. Grimes.Pp
5029b50d902SRodney W. GrimesHistoric implementations of the
5039b50d902SRodney W. Grimes.Ic exec
5049b50d902SRodney W. Grimesand
5059b50d902SRodney W. Grimes.Ic ok
5069b50d902SRodney W. Grimesprimaries did not replace the string ``{}'' in the utility name or the
5079b50d902SRodney W. Grimesutility arguments if it had preceding or following non-whitespace characters.
5089b50d902SRodney W. GrimesThis version replaces it no matter where in the utility name or arguments
5099b50d902SRodney W. Grimesit appears.
5109b50d902SRodney W. Grimes.Sh BUGS
5119b50d902SRodney W. GrimesThe special characters used by
5129b50d902SRodney W. Grimes.Nm find
5139b50d902SRodney W. Grimesare also special characters to many shell programs.
5149b50d902SRodney W. GrimesIn particular, the characters ``*'', ``['', ``]'', ``?'', ``('', ``)'',
5159b50d902SRodney W. Grimes``!'', ``\e'' and ``;'' may have to be escaped from the shell.
5169b50d902SRodney W. Grimes.Pp
5179b50d902SRodney W. GrimesAs there is no delimiter separating options and file names or file
5189b50d902SRodney W. Grimesnames and the
5199b50d902SRodney W. Grimes.Ar expression ,
5209b50d902SRodney W. Grimesit is difficult to specify files named ``-xdev'' or ``!''.
5219b50d902SRodney W. GrimesThese problems are handled by the
5229b50d902SRodney W. Grimes.Fl f
5239b50d902SRodney W. Grimesoption and the
5249b50d902SRodney W. Grimes.Xr getopt 3
5259b50d902SRodney W. Grimes``--'' construct.
526abacbbbfSPeter Wemm.Pp
527abacbbbfSPeter WemmThe
528abacbbbfSPeter Wemm.Ic -delete
52956f7a840SBill Fumerolaprimary does not interact well with other options that cause the filesystem
530abacbbbfSPeter Wemmtree traversal options to be changed.
531b8923d4cSWolfram Schneider.Sh HISTORY
532b8923d4cSWolfram SchneiderA
533b8923d4cSWolfram Schneider.Nm
534b8923d4cSWolfram Schneidercommand appeared in
535b8923d4cSWolfram Schneider.At v1 .
536