📄 find.html
字号:
</dd><dt><b>-ok </b> <i>utility_name </i> <b>[</b><i>argument</i> ...<b>] ;</b></dt><dd><br>The <b>-ok</b> primary shall be equivalent to <b>-exec</b>, except that the use of a plus sign to punctuate the end of the primaryexpression need not be supported, and <i>find</i> shall request affirmation of the invocation of <i>utility_name</i> using thecurrent file as an argument by writing to standard error as described in the STDERR section. If the response on standard input isaffirmative, the utility shall be invoked. Otherwise, the command shall not be invoked and the value of the <b>-ok</b> operandshall be false.</dd><dt><b>-print</b></dt><dd>The primary shall always evaluate as true; it shall cause the current pathname to be written to standard output.</dd><dt><b>-newer </b> <i>file</i></dt><dd>The primary shall evaluate as true if the modification time of the current file is more recent than the modification time ofthe file named by the pathname <i>file</i>.</dd><dt><b>-depth</b></dt><dd>The primary shall always evaluate as true; it shall cause descent of the directory hierarchy to be done so that all entries ina directory are acted on before the directory itself. If a <b>-depth</b> primary is not specified, all entries in a directory shallbe acted on after the directory itself. If any <b>-depth</b> primary is specified, it shall apply to the entire expression even ifthe <b>-depth</b> primary would not normally be evaluated.</dd></dl><p>The primaries can be combined using the following operators (in order of decreasing precedence):</p><dl compact><dt>( <i>expression</i> )</dt><dd>True if <i>expression</i> is true.</dd><dt><b>! </b> <i>expression</i></dt><dd>Negation of a primary; the unary NOT operator.</dd><dt><i>expression </i> <b>[-a] </b> <i>expression</i></dt><dd><br>Conjunction of primaries; the AND operator is implied by the juxtaposition of two primaries or made explicit by the optional<b>-a</b> operator. The second expression shall not be evaluated if the first expression is false.</dd><dt><i>expression </i> <b>-o </b> <i>expression</i></dt><dd><br>Alternation of primaries; the OR operator. The second expression shall not be evaluated if the first expression is true.</dd></dl><p>If no <i>expression</i> is present, <b>-print</b> shall be used as the expression. Otherwise, if the given expression does notcontain any of the primaries <b>-exec</b>, <b>-ok</b>, or <b>-print</b>, the given expression shall be effectively replaced by:</p><pre><tt>(</tt> <i>given_expression</i> <tt>) -print</tt></pre><p>The <b>-user</b>, <b>-group</b>, and <b>-newer</b> primaries each shall evaluate their respective arguments only once.</p></blockquote><h4><a name="tag_04_55_06"></a>STDIN</h4><blockquote><p>If the <b>-ok</b> primary is used, the response shall be read from the standard input. An entire line shall be read as theresponse. Otherwise, the standard input shall not be used.</p></blockquote><h4><a name="tag_04_55_07"></a>INPUT FILES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_55_08"></a>ENVIRONMENT VARIABLES</h4><blockquote><p>The following environment variables shall affect the execution of <i>find</i>:</p><dl compact><dt><i>LANG</i></dt><dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume ofIEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> forthe precedence of internationalization variables used to determine the values of locale categories.)</dd><dt><i>LC_ALL</i></dt><dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd><dt><i>LC_COLLATE</i></dt><dd><br>Determine the locale for the behavior of ranges, equivalence classes, and multi-character collating elements used in the patternmatching notation for the <b>-n</b> option and in the extended regular expression defined for the <b>yesexpr</b> locale keyword inthe <i>LC_MESSAGES</i> category.</dd><dt><i>LC_CTYPE</i></dt><dd>This variable determines the locale for the interpretation of sequences of bytes of text data as characters (for example,single-byte as opposed to multi-byte characters in arguments), the behavior of character classes within the pattern matchingnotation used for the <b>-n</b> option, and the behavior of character classes within regular expressions used in the extendedregular expression defined for the <b>yesexpr</b> locale keyword in the <i>LC_MESSAGES</i> category.</dd><dt><i>LC_MESSAGES</i></dt><dd>Determine the locale for the processing of affirmative responses that should be used to affect the format and contents ofdiagnostic messages written to standard error.</dd><dt><i>NLSPATH</i></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt><i>PATH</i></dt><dd>Determine the location of the <i>utility_name</i> for the <b>-exec</b> and <b>-ok</b> primaries, as described in the BaseDefinitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html">Chapter 8, EnvironmentVariables</a>.</dd></dl></blockquote><h4><a name="tag_04_55_09"></a>ASYNCHRONOUS EVENTS</h4><blockquote><p>Default.</p></blockquote><h4><a name="tag_04_55_10"></a>STDOUT</h4><blockquote><p>The <b>-print</b> primary shall cause the current pathnames to be written to standard output. The format shall be:</p><pre><tt>"%s\n", <</tt><i>path</i><tt>></tt></pre></blockquote><h4><a name="tag_04_55_11"></a>STDERR</h4><blockquote><p>The <b>-ok</b> primary shall write a prompt to standard error containing at least the <i>utility_name</i> to be invoked and thecurrent pathname. In the POSIX locale, the last non- <blank> in the prompt shall be <tt>'?'</tt> . The exact format used isunspecified.</p><p>Otherwise, the standard error shall be used only for diagnostic messages.</p></blockquote><h4><a name="tag_04_55_12"></a>OUTPUT FILES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_55_13"></a>EXTENDED DESCRIPTION</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_55_14"></a>EXIT STATUS</h4><blockquote><p>The following exit values shall be returned:</p><dl compact><dt> 0</dt><dd>All <i>path</i> operands were traversed successfully.</dd><dt>>0</dt><dd>An error occurred.</dd></dl></blockquote><h4><a name="tag_04_55_15"></a>CONSEQUENCES OF ERRORS</h4><blockquote><p>Default.</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_04_55_16"></a>APPLICATION USAGE</h4><blockquote><p>When used in operands, pattern matching notation, semicolons, opening parentheses, and closing parentheses are special to theshell and must be quoted (see <a href="xcu_chap02.html#tag_02_02"><i>Quoting</i></a> ).</p><p>The bit that is traditionally used for sticky (historically 01000) is specified in the <b>-perm</b> primary using the octalnumber argument form. Since this bit is not defined by this volume of IEEE Std 1003.1-2001, applications must not assumethat it actually refers to the traditional sticky bit.</p></blockquote><h4><a name="tag_04_55_17"></a>EXAMPLES</h4><blockquote><ol><li><p>The following commands are equivalent:</p><pre><tt>find .find . -print</tt></pre><p>They both write out the entire directory hierarchy from the current directory.</p></li><li><p>The following command:</p><pre><tt>find / \( -name tmp -o -name '*.xx' \) -atime +7 -exec rm {} \;</tt></pre><p>removes all files named <b>tmp</b> or ending in <b>.xx</b> that have not been accessed for seven or more 24-hour periods.</p></li><li><p>The following command:</p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -