📄 find.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>find</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="find"></a> <a name="tag_04_55"></a><!-- find --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_04_55_01"></a>NAME</h4><blockquote>find - find files</blockquote><h4><a name="tag_04_55_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>find</tt> <b>[</b><tt>-H | -L</tt><b>]</b> <i>path</i> <tt>...</tt> <b>[</b><i>operand_expression</i> <tt>...</tt><b>]</b></code></p></blockquote><h4><a name="tag_04_55_03"></a>DESCRIPTION</h4><blockquote><p>The <i>find</i> utility shall recursively descend the directory hierarchy from each file specified by <i>path</i>, evaluating aBoolean expression composed of the primaries described in the OPERANDS section for each file encountered.</p><p>The <i>find</i> utility shall be able to descend to arbitrary depths in a file hierarchy and shall not fail due to path lengthlimitations (unless a <i>path</i> operand specified by the application exceeds {PATH_MAX} requirements).</p><p>The <i>find</i> utility shall detect infinite loops; that is, entering a previously visited directory that is an ancestor of thelast file encountered. When it detects an infinite loop, <i>find</i> shall write a diagnostic message to standard error and shalleither recover its position in the hierarchy or terminate.</p></blockquote><h4><a name="tag_04_55_04"></a>OPTIONS</h4><blockquote><p>The <i>find</i> utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p><p>The following options shall be supported by the implementation:</p><dl compact><dt><b>-H</b></dt><dd>Cause the file information and file type evaluated for each symbolic link encountered on the command line to be those of thefile referenced by the link, and not the link itself. If the referenced file does not exist, the file information and type shall befor the link itself. File information for all symbolic links not on the command line shall be that of the link itself.</dd><dt><b>-L</b></dt><dd>Cause the file information and file type evaluated for each symbolic link to be those of the file referenced by the link, andnot the link itself.</dd></dl><p>Specifying more than one of the mutually-exclusive options <b>-H</b> and <b>-L</b> shall not be considered an error. The lastoption specified shall determine the behavior of the utility.</p></blockquote><h4><a name="tag_04_55_05"></a>OPERANDS</h4><blockquote><p>The following operands shall be supported:</p><p>The <i>path</i> operand is a pathname of a starting point in the directory hierarchy.</p><p>The first argument that starts with a <tt>'-'</tt> , or is a <tt>'!'</tt> or a <tt>'('</tt> , and all subsequent arguments shallbe interpreted as an <i>expression</i> made up of the following primaries and operators. In the descriptions, wherever <i>n</i> isused as a primary argument, it shall be interpreted as a decimal integer optionally preceded by a plus ( <tt>'+'</tt> ) or minus (<tt>'-'</tt> ) sign, as follows:</p><dl compact><dt>+<i>n</i></dt><dd>More than <i>n</i>.</dd><dt><i>n</i></dt><dd>Exactly <i>n</i>.</dd><dt>-<i>n</i></dt><dd>Less than <i>n</i>.</dd></dl><p>The following primaries shall be supported:</p><dl compact><dt><b>-name </b> <i>pattern</i></dt><dd><br>The primary shall evaluate as true if the basename of the filename being examined matches <i>pattern</i> using the pattern matchingnotation described in <a href="xcu_chap02.html#tag_02_13"><i>Pattern Matching Notation</i></a> .</dd><dt><b>-nouser</b></dt><dd>The primary shall evaluate as true if the file belongs to a user ID for which the <a href="../functions/getpwuid.html"><i>getpwuid</i>()</a> function defined in the System Interfaces volume ofIEEE Std 1003.1-2001 (or equivalent) returns NULL.</dd><dt><b>-nogroup</b></dt><dd>The primary shall evaluate as true if the file belongs to a group ID for which the <a href="../functions/getgrgid.html"><i>getgrgid</i>()</a> function defined in the System Interfaces volume ofIEEE Std 1003.1-2001 (or equivalent) returns NULL.</dd><dt><b>-xdev</b></dt><dd>The primary shall always evaluate as true; it shall cause <i>find</i> not to continue descending past directories that have adifferent device ID ( <i>st_dev</i>, see the <a href="../functions/stat.html"><i>stat</i>()</a> function defined in the SystemInterfaces volume of IEEE Std 1003.1-2001). If any <b>-xdev</b> primary is specified, it shall apply to the entireexpression even if the <b>-xdev</b> primary would not normally be evaluated.</dd><dt><b>-prune</b></dt><dd>The primary shall always evaluate as true; it shall cause <i>find</i> not to descend the current pathname if it is a directory.If the <b>-depth</b> primary is specified, the <b>-prune</b> primary shall have no effect.</dd><dt><b>-perm [-]</b><i>mode</i></dt><dd><br>The <i>mode</i> argument is used to represent file mode bits. It shall be identical in format to the <i>symbolic_mode</i> operanddescribed in <a href="chmod.html"><i>chmod</i>()</a> , and shall be interpreted as follows. To start, a template shall be assumedwith all file mode bits cleared. An <i>op</i> symbol of <tt>'+'</tt> shall set the appropriate mode bits in the template;<tt>'-'</tt> shall clear the appropriate bits; <tt>'='</tt> shall set the appropriate mode bits, without regard to the contents ofprocess' file mode creation mask. The <i>op</i> symbol of <tt>'-'</tt> cannot be the first character of <i>mode</i>; this avoidsambiguity with the optional leading hyphen. Since the initial mode is all bits off, there are not any symbolic modes that need touse <tt>'-'</tt> as the first character. <p>If the hyphen is omitted, the primary shall evaluate as true when the file permission bits exactly match the value of theresulting template.</p><p>Otherwise, if <i>mode</i> is prefixed by a hyphen, the primary shall evaluate as true if at least all the bits in the resultingtemplate are set in the file permission bits.</p></dd><dt><b>-perm [-]</b><i>onum</i></dt><dd><br>If the hyphen is omitted, the primary shall evaluate as true when the file permission bits exactly match the value of the octalnumber <i>onum</i> and only the bits corresponding to the octal mask 07777 shall be compared. (See the description of the octal<i>mode</i> in <a href="chmod.html"><i>chmod</i>()</a> .) Otherwise, if <i>onum</i> is prefixed by a hyphen, the primary shallevaluate as true if at least all of the bits specified in <i>onum</i> that are also set in the octal mask 07777 are set.</dd><dt><b>-type </b> <i>c</i></dt><dd>The primary shall evaluate as true if the type of the file is <i>c</i>, where <i>c</i> is <tt>'b'</tt> , <tt>'c'</tt> ,<tt>'d'</tt> , <tt>'l'</tt> , <tt>'p'</tt> , <tt>'f'</tt> , or <tt>'s'</tt> for block special file, character special file,directory, symbolic link, FIFO, regular file, or socket, respectively.</dd><dt><b>-links </b> <i>n</i></dt><dd>The primary shall evaluate as true if the file has <i>n</i> links.</dd><dt><b>-user </b> <i>uname</i></dt><dd>The primary shall evaluate as true if the file belongs to the user <i>uname.</i> If <i>uname</i> is a decimal integer and the<a href="../functions/getpwnam.html"><i>getpwnam</i>()</a> (or equivalent) function does not return a valid user name, <i>uname</i>shall be interpreted as a user ID.</dd><dt><b>-group </b> <i>gname</i></dt><dd><br>The primary shall evaluate as true if the file belongs to the group <i>gname</i>. If <i>gname</i> is a decimal integer and the <ahref="../functions/getgrnam.html"><i>getgrnam</i>()</a> (or equivalent) function does not return a valid group name, <i>gname</i>shall be interpreted as a group ID.</dd><dt><b>-size </b> <i>n</i><b>[c]</b></dt><dd>The primary shall evaluate as true if the file size in bytes, divided by 512 and rounded up to the next integer, is <i>n</i>.If <i>n</i> is followed by the character <tt>'c'</tt> , the size shall be in bytes.</dd><dt><b>-atime </b> <i>n</i></dt><dd>The primary shall evaluate as true if the file access time subtracted from the initialization time, divided by 86400 (with anyremainder discarded), is <i>n</i>.</dd><dt><b>-ctime </b> <i>n</i></dt><dd>The primary shall evaluate as true if the time of last change of file status information subtracted from the initializationtime, divided by 86400 (with any remainder discarded), is <i>n</i>.</dd><dt><b>-mtime </b> <i>n</i></dt><dd>The primary shall evaluate as true if the file modification time subtracted from the initialization time, divided by 86400(with any remainder discarded), is <i>n</i>.</dd><dt><b>-exec </b> <i>utility_name </i> <b>[</b><i>argument</i> ...<b>] ;</b></dt><dt><b>-exec </b> <i>utility_name </i> <b>[</b><i>argument</i> ...<b>] </b> {} +</dt><dd><br>The end of the primary expression shall be punctuated by a semicolon or by a plus sign. Only a plus sign that follows an argumentcontaining the two characters <tt>"{}"</tt> shall punctuate the end of the primary expression. Other uses of the plus sign shallnot be treated as special. <p>If the primary expression is punctuated by a semicolon, the utility <i>utility_name</i> shall be invoked once for each pathnameand the primary shall evaluate as true if the utility returns a zero value as exit status. A <i>utility_name</i> or <i>argument</i>containing only the two characters <tt>"{}"</tt> shall be replaced by the current pathname.</p><p>If the primary expression is punctuated by a plus sign, the primary shall always evaluate as true, and the pathnames for whichthe primary is evaluated shall be aggregated into sets. The utility <i>utility_name</i> shall be invoked once for each set ofaggregated pathnames. Each invocation shall begin after the last pathname in the set is aggregated, and shall be completed beforethe <i>find</i> utility exits and before the first pathname in the next set (if any) is aggregated for this primary, but it isotherwise unspecified whether the invocation occurs before, during, or after the evaluations of other primaries. If any invocationreturns a non-zero value as exit status, the <i>find</i> utility shall return a non-zero exit status. An argument containing onlythe two characters <tt>"{}"</tt> shall be replaced by the set of aggregated pathnames, with each pathname passed as a separateargument to the invoked utility in the same order that it was aggregated. The size of any set of two or more pathnames shall belimited such that execution of the utility does not cause the system's {ARG_MAX} limit to be exceeded. If more than one argumentcontaining only the two characters <tt>"{}"</tt> is present, the behavior is unspecified.</p><p>If a <i>utility_name</i> or <i>argument</i> string contains the two characters <tt>"{}"</tt> , but not just the two characters<tt>"{}"</tt> , it is implementation-defined whether <i>find</i> replaces those two characters or uses the string without change.The current directory for the invocation of <i>utility_name</i> shall be the same as the current directory when the <i>find</i>utility was started. If the <i>utility_name</i> names any of the special built-in utilities (see <a href="xcu_chap02.html#tag_02_14"><i>Special Built-In Utilities</i></a> ), the results are undefined.</p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -