find.1
来自「早期freebsd实现」· 1 代码 · 共 455 行
1
455 行
.\" Copyright (c) 1990, 1993.\" The Regents of the University of California. All rights reserved..\".\" This code is derived from software contributed to Berkeley by.\" the Institute of Electrical and Electronics Engineers, Inc..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\" notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\" notice, this list of conditions and the following disclaimer in the.\" documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\" must display the following acknowledgement:.\" This product includes software developed by the University of.\" California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\" may be used to endorse or promote products derived from this software.\" without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\" @(#)find.1 8.4 (Berkeley) 4/1/94.\".Dd April 1, 1994.Dt FIND 1.Os.Sh NAME.Nm find.Nd walk a file hierarchy.Sh SYNOPSIS.Nm find.Op Fl H | Fl L | Fl P.Op Fl Xdx.Op Fl f Ar file.Op Ar file ....Ar expression.Sh DESCRIPTION.Nm Findrecursively descends the directory tree for each.Ar filelisted, evaluating an.Ar expression(composed of the ``primaries'' and ``operands'' listed below) in termsof each file in the tree..PpThe options are as follows:.Pp.Bl -tag -width Ds.It Fl HThe.Fl Hoption causes the file information and file type (see.Xr stat 2)returned for each symbolic link specified on the command line to be those of the file referenced by the link, not the link itself.If the referenced file does not exist, the file information and type willbe for the link itself. File information of all symbolic links not on the command line is that of the link itself..It Fl LThe.Fl Loption causes the file information and file type (see.Xr stat 2)returned for each symbolic link to be those of the file referenced by thelink, not the link itself.If the referenced file does not exist, the file information and type willbe for the link itself..It Fl PThe.Fl Poption causes the file information and file type (see.Xr stat 2)returned for each symbolic link to be those of the link itself..It Fl XThe.Fl Xoption is a modification to permit.Nmto be safely used in conjunction with.Xr xargs 1 .If a file name contains any of the delimiting characters used by.Xr xargs ,a diagnostic message is displayed on standard error, and the fileis skipped.The delimiting characters include single (`` ' '') and double (`` " '')quotes, backslash (``\e''), space, tab and newline characters..It Fl dThe.Fl doption causes.Nm findto perform a depth\-first traversal, i.e. directoriesare visited in post\-order and all entries in a directory will be actedon before the directory itself.By default,.Nm findvisits directories in pre\-order, i.e. before their contents.Note, the default is.Ar nota breadth\-first traversal..It Fl fThe.Fl foption specifies a file hierarchy for.Nm findto traverse.File hierarchies may also be specified as the operands immediatelyfollowing the options..It Fl xThe.Fl xoption prevents.Nm findfrom descending into directories that have a device number differentthan that of the file from which the descent began..El.Sh PRIMARIES.Bl -tag -width Ds.It Ic -atime Ar n True if the difference between the file last access time and the time.Nm findwas started, rounded up to the next full 24\-hour period, is.Ar n24\-hour periods..It Ic -ctime Ar n True if the difference between the time of last change of file statusinformation and the time.Nm findwas started, rounded up to the next full 24\-hour period, is.Ar n24\-hour periods..It Ic -exec Ar utility Op argument ... ; True if the program named.Ar utilityreturns a zero value as its exit status.Optional arguments may be passed to the utility.The expression must be terminated by a semicolon (``;'').If the string ``{}'' appears anywhere in the utility name or thearguments it is replaced by the pathname of the current file..Ar Utilitywill be executed from the directory from which.Nm findwas executed..It Ic -fstype Ar type True if the file is contained in a file system of type.Ar type .Currently supported types are ``local'', ``mfs'', ``nfs'', ``msdos'',``rdonly'' and ``ufs''.The types ``local'' and ``rdonly'' are not specific file system types.The former matches any file system physically mounted on the system wherethe.Nm findis being executed and the latter matches any file system which ismounted read-only..It Ic -group Ar gname True if the file belongs to the group.Ar gname .If.Ar gnameis numeric and there is no such group name, then.Ar gnameis treated as a group id..It Ic -inum Ar n True if the file has inode number.Ar n ..It Ic -links Ar n True if the file has.Ar nlinks..It Ic -lsThis primary always evaluates to true.The following information for the current file is written to standard output:its inode number, size in 512\-byte blocks, file permissions, number of hardlinks, owner, group, size in bytes, last modification time, and pathname.If the file is a block or character special file, the major and minor numberswill be displayed instead of the size in bytes.If the file is a symbolic link, the pathname of the linked\-to file will bedisplayed preceded by ``\->''.The format is identical to that produced by ``ls \-dgils''..It Ic -mtime Ar n True if the difference between the file last modification time and the time.Nm findwas started, rounded up to the next full 24\-hour period, is.Ar n24\-hour periods..It Ic \&-ok Ar utility Ns Op argument ... ; The.Ic \&-okprimary is identical to the.Ic -execprimary with the exception that.Nm findrequests user affirmation for the execution of the utility by printinga message to the terminal and reading a response.If the response is other than ``y'' the command is not executed and thevalue of the.Ar \&okexpression is false..It Ic -name Ar pattern True if the last component of the pathname being examined matches.Ar pattern .Special shell pattern matching characters (``['', ``]'', ``*'', and ``?'')may be used as part of.Ar pattern .These characters may be matched explicitly by escaping them with abackslash (``\e'')..It Ic -newer Ar file True if the current file has a more recent last modification time than.Ar file ..It Ic -nouserTrue if the file belongs to an unknown user..It Ic -nogroupTrue if the file belongs to an unknown group..It Ic -path Ar pattern True if the pathname being examined matches.Ar pattern .Special shell pattern matching characters (``['', ``]'', ``*'', and ``?'')may be used as part of.Ar pattern .These characters may be matched explicitly by escaping them with abackslash (``\e'').Slashes (``/'') are treated as normal characters and do not have to bematched explicitly..It Ic -perm Op Fl Ns Ar mode The.Ar modemay be either symbolic (see.Xr chmod 1 )or an octal number.If the mode is symbolic, a starting value of zero is assumed and themode sets or clears permissions without regard to the process' file modecreation mask.If the mode is octal, only bits 07777.Pf ( Dv S_ISUID|.Dv S_ISGID|.Dv S_ISTXT|.Dv S_IRWXU|.Dv S_IRWXG|.Dv S_IRWXO )of the file's mode bits participatein the comparison.If the mode is preceded by a dash (``\-''), this primary evaluates to trueif at least all of the bits in the mode are set in the file's mode bits.If the mode is not preceded by a dash, this primary evaluates to true ifthe bits in the mode exactly match the file's mode bits.Note, the first character of a symbolic mode may not be a dash (``\-'')..It Ic -printThis primary always evaluates to true.It prints the pathname of the current file to standard output.The expression is appended to the user specified expression if neither.Ic -exec ,.Ic -lsor.Ic \&-okis specified..It Ic -pruneThis primary always evaluates to true.It causes.Nm findto not descend into the current file.Note, the.Ic -pruneprimary has no effect if the.Fl doption was specified..It Ic -size Ar n Ns Op Cm c True if the file's size, rounded up, in 512\-byte blocks is.Ar n .If.Ar nis followed by a ``c'', then the primary is true if thefile's size is.Ar nbytes..It Ic -type Ar t True if the file is of the specified type.Possible file types are as follows:.Pp.Bl -tag -width flag -offset indent -compact.It Cm bblock special.It Cm ccharacter special.It Cm ddirectory.It Cm fregular file.It Cm lsymbolic link.It Cm pFIFO.It Cm ssocket.El.Pp.It Ic -user Ar uname True if the file belongs to the user.Ar uname .If.Ar unameis numeric and there is no such user name, then.Ar unameis treated as a user id..El.PpAll primaries which take a numeric argument allow the number to bepreceded by a plus sign (``+'') or a minus sign (``\-'').A preceding plus sign means ``more than n'', a preceding minus sign means``less than n'' and neither means ``exactly n'' ..Sh OPERATORSThe primaries may be combined using the following operators.The operators are listed in order of decreasing precedence..Bl -tag -width (expression) .It Cm \&( Ns Ar expression Ns Cm \&) This evaluates to true if the parenthesized expression evaluates totrue..Pp.It Cm \&! Ns Ar expression This is the unary.Tn NOToperator.It evaluates to true if the expression is false..Pp.It Ar expression Cm -and Ar expression .It Ar expression expression The.Cm -andoperator is the logical.Tn ANDoperator.As it is implied by the juxtaposition of two expressions it does nothave to be specified.The expression evaluates to true if both expressions are true.The second expression is not evaluated if the first expression is false..Pp.It Ar expression Cm -or Ar expression The.Cm -oroperator is the logical.Tn ORoperator.The expression evaluates to true if either the first or the second expressionis true.The second expression is not evaluated if the first expression is true..El.PpAll operands and primaries must be separate arguments to.Nm find .Primaries which themselves take arguments expect each argumentto be a separate argument to.Nm find ..Sh EXAMPLES.PpThe following examples are shown as given to the shell:.Bl -tag -width findx.It Li "find / \e! -name \*q*.c\*q -print"Print out a list of all the files whose names do not end in ``.c''..It Li "find / -newer ttt -user wnj -print"Print out a list of all the files owned by user ``wnj'' that are newerthan the file ``ttt''..It Li "find / \e! \e( -newer ttt -user wnj \e) -print"Print out a list of all the files which are not both newer than ``ttt''and owned by ``wnj''..It Li "find / \e( -newer ttt -or -user wnj \e) -print"Print out a list of all the files that are either owned by ``wnj'' orthat are newer than ``ttt''..El.Sh SEE ALSO.Xr chmod 1 ,.Xr locate 1 ,.Xr stat 2 ,.Xr fts 3 ,.Xr getgrent 3 ,.Xr getpwent 3 ,.Xr strmode 3 ,.Xr symlink 7.Sh STANDARDSThe.Nm findutility syntax is a superset of the syntax specified by the.St -p1003.2standard..PpThe.Fl sand.Fl Xoptions and the.Ic -inumand.Ic -lsprimaries are extensions to.St -p1003.2 ..PpHistorically, the.Fl d ,.Fl hand.Fl xoptions were implemented using the primaries ``\-depth'', ``\-follow'',and ``\-xdev''.These primaries always evaluated to true.As they were really global variables that took effect before the traversalbegan, some legal expressions could have unexpected results.An example is the expression ``\-print \-o \-depth''.As \-print always evaluates to true, the standard order of evaluationimplies that \-depth would never be evaluated.This is not the case..PpThe operator ``-or'' was implemented as ``\-o'', and the operator ``-and''was implemented as ``\-a''..PpHistoric implementations of the.Ic execand.Ic okprimaries did not replace the string ``{}'' in the utility name or theutility arguments if it had preceding or following non-whitespace characters.This version replaces it no matter where in the utility name or argumentsit appears..Sh BUGSThe special characters used by.Nm findare also special characters to many shell programs.In particular, the characters ``*'', ``['', ``]'', ``?'', ``('', ``)'',``!'', ``\e'' and ``;'' may have to be escaped from the shell..PpAs there is no delimiter separating options and file names or filenames and the.Ar expression ,it is difficult to specify files named ``-xdev'' or ``!''.These problems are handled by the.Fl foption and the.Xr getopt 3``--'' construct.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?