📄 xargs.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>xargs</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="xargs"></a> <a name="tag_04_173"></a><!-- xargs --> <!--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_173_01"></a>NAME</h4><blockquote>xargs - construct argument lists and invoke utility</blockquote><h4><a name="tag_04_173_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> xargs</tt><b>[</b><tt>-t</tt><b>][</b><tt>-p</tt><b>]][</b><tt>-E</tt> <i>eofstr</i><b>]<img src="../images/opt-start.gif" border="0">[</b><tt>-I</tt> <i>replstr</i><b>][</b><tt>-L</tt> <i>number</i><b>]<img src="../images/opt-end.gif" border="0">[</b><tt>-n</tt> <i>number</i> <b>[</b><tt>-x</tt><b>]]<br></b> <tt> </tt> <b>[</b><tt>-s</tt> <i>size</i><b>][</b><i>utility</i><b>[</b><i>argument</i><tt>...</tt><b>]]</b></code></p></blockquote><h4><a name="tag_04_173_03"></a>DESCRIPTION</h4><blockquote><p>The <i>xargs</i> utility shall construct a command line consisting of the <i>utility</i> and <i>argument</i> operands specifiedfollowed by as many arguments read in sequence from standard input as fit in length and number constraints specified by theoptions. The <i>xargs</i> utility shall then invoke the constructed command line and wait for its completion. This sequence shallbe repeated until one of the following occurs:</p><ul><li><p>An end-of-file condition is detected on standard input.</p></li><li><p>The logical end-of-file string (see the <b>-E</b> <i>eofstr</i> option) is found on standard input after double-quoteprocessing, apostrophe processing, and backslash escape processing (see next paragraph).</p></li><li><p>An invocation of a constructed command line returns an exit status of 255.</p></li></ul><p>The application shall ensure that arguments in the standard input are separated by unquoted <blank>s, unescaped<blank>s, or <newline>s. A string of zero or more non-double-quote ( <tt>' )'</tt> characters and non- <newline>scan be quoted by enclosing them in double-quotes. A string of zero or more non-apostrophe ( <tt>'"</tt> ) characters and non-<newline>s can be quoted by enclosing them in apostrophes. Any unquoted character can be escaped by preceding it with abackslash. The utility named by <i>utility</i> shall be executed one or more times until the end-of-file is reached or the logicalend-of file string is found. The results are unspecified if the utility named by <i>utility</i> attempts to read from its standardinput.</p><p>The generated command line length shall be the sum of the size in bytes of the utility name and each argument treated asstrings, including a null byte terminator for each of these strings. The <i>xargs</i> utility shall limit the command line lengthsuch that when the command line is invoked, the combined argument and environment lists (see the <i>exec</i> family of functions inthe System Interfaces volume of IEEE Std 1003.1-2001) shall not exceed {ARG_MAX}-2048 bytes. Within this constraint, ifneither the <b>-n</b> nor the <b>-s</b> option is specified, the default command line length shall be at least {LINE_MAX}.</p></blockquote><h4><a name="tag_04_173_04"></a>OPTIONS</h4><blockquote><p>The <i>xargs</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:</p><dl compact><dt><b>-E </b> <i>eofstr</i></dt><dd>Use <i>eofstr</i> as the logical end-of-file string. If <b>-E</b> is not specified, it is unspecified whether the logicalend-of-file string is the underscore character ( <tt>'_'</tt> ) or the end-of-file string capability is disabled. When<i>eofstr</i> is the null string, the logical end-of-file string capability shall be disabled and underscore characters shall betaken literally.</dd><dt><b>-I </b> <i>replstr</i></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Insert mode: <i>utility</i> is executed for each line from standard input, taking the entire line as a single argument, insertingit in <i>argument</i>s for each occurrence of <i>replstr</i>. A maximum of five arguments in <i>argument</i>s can each contain oneor more instances of <i>replstr</i>. Any <blank>s at the beginning of each line shall be ignored. Constructed argumentscannot grow larger than 255 bytes. Option <b>-x</b> shall be forced on. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt><b>-L </b> <i>number</i></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The <i>utility</i> shall be executed for each non-empty <i>number</i> lines of arguments from standard input. The last invocationof <i>utility</i> shall be with fewer lines of arguments if fewer than <i>number</i> remain. A line is considered to end with thefirst <newline> unless the last character of the line is a <blank>; a trailing <blank> signals continuation tothe next non-empty line, inclusive. The <b>-L</b> and <b>-n</b> options are mutually-exclusive; the last one specified shall takeeffect. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt><b>-n </b> <i>number</i></dt><dd>Invoke <i>utility</i> using as many standard input arguments as possible, up to <i>number</i> (a positive decimal integer)arguments maximum. Fewer arguments shall be used if: <ul><li><p>The command line length accumulated exceeds the size specified by the <b>-s</b> option (or {LINE_MAX} if there is no <b>-s</b>option).</p></li><li><p>The last iteration has fewer than <i>number</i>, but not zero, operands remaining.</p></li></ul></dd><dt><b>-p</b></dt><dd>Prompt mode: the user is asked whether to execute <i>utility</i> at each invocation. Trace mode ( <b>-t</b>) is turned on towrite the command instance to be executed, followed by a prompt to standard error. An affirmative response read from<b>/dev/tty</b> shall execute the command; otherwise, that particular invocation of <i>utility</i> shall be skipped.</dd><dt><b>-s </b> <i>size</i></dt><dd>Invoke <i>utility</i> using as many standard input arguments as possible yielding a command line length less than <i>size</i>(a positive decimal integer) bytes. Fewer arguments shall be used if: <ul><li><p>The total number of arguments exceeds that specified by the <b>-n</b> option.</p></li><li><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The total number of lines exceeds that specified by the <b>-L</b> option. <img src="../images/opt-end.gif" alt="[Option End]"border="0"></p></li><li><p>End-of-file is encountered on standard input before <i>size</i> bytes are accumulated.</p></li></ul><p>Values of <i>size</i> up to at least {LINE_MAX} bytes shall be supported, provided that the constraints specified in theDESCRIPTION are met. It shall not be considered an error if a value larger than that supported by the implementation or exceedingthe constraints specified in the DESCRIPTION is given; <i>xargs</i> shall use the largest value it supports within theconstraints.</p></dd><dt><b>-t</b></dt><dd>Enable trace mode. Each generated command line shall be written to standard error just prior to invocation.</dd><dt><b>-x</b></dt><dd>Terminate if a command line containing <i>number</i> arguments (see the <b>-n</b> option above) <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> or<i>number</i> lines (see the <b>-L</b> option above) <img src="../images/opt-end.gif" alt="[Option End]" border="0"> will not fitin the implied or specified size (see the <b>-s</b> option above).</dd></dl></blockquote><h4><a name="tag_04_173_05"></a>OPERANDS</h4><blockquote><p>The following operands shall be supported:</p><dl compact><dt><i>utility</i></dt><dd>The name of the utility to be invoked, found by search path using the <i>PATH</i> environment variable, described in the BaseDefinitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html">Chapter 8, Environment Variables</a>.If <i>utility</i> is omitted, the default shall be the <a href="../utilities/echo.html"><i>echo</i></a> utility. If the<i>utility</i> operand names any of the special built-in utilities in <a href="xcu_chap02.html#tag_02_14"><i>Special Built-InUtilities</i></a> , the results are undefined.</dd><dt><i>argument</i></dt><dd>An initial option or operand for the invocation of <i>utility</i>.</dd></dl></blockquote><h4><a name="tag_04_173_06"></a>STDIN</h4><blockquote><p>The standard input shall be a text file. The results are unspecified if an end-of-file condition is detected immediatelyfollowing an escaped <newline>.</p></blockquote><h4><a name="tag_04_173_07"></a>INPUT FILES</h4><blockquote><p>The file <b>/dev/tty</b> shall be used to read responses required by the <b>-p</b> option.</p></blockquote><h4><a name="tag_04_173_08"></a>ENVIRONMENT VARIABLES</h4><blockquote><p>The following environment variables shall affect the execution of <i>xargs</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 extendedregular expression defined for the <b>yesexpr</b> locale keyword in the <i>LC_MESSAGES</i> category.</dd><dt><i>LC_CTYPE</i></dt><dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte asopposed to multi-byte characters in arguments and input files) and the behavior of character classes used in the extended regularexpression 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 and 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 <i>utility</i>, as described in the Base Definitions volume of IEEE Std 1003.1-2001, <ahref="../basedefs/xbd_chap08.html">Chapter 8, Environment Variables</a>.</dd></dl></blockquote><h4><a name="tag_04_173_09"></a>ASYNCHRONOUS EVENTS</h4><blockquote><p>Default.</p></blockquote><h4><a name="tag_04_173_10"></a>STDOUT</h4><blockquote><p>Not used.</p></blockquote><h4><a name="tag_04_173_11"></a>STDERR</h4><blockquote><p>The standard error shall be used for diagnostic messages and the <b>-t</b> and <b>-p</b> options. If the <b>-t</b> option isspecified, the <i>utility</i> and its constructed argument list shall be written to standard error, as it will be invoked, prior toinvocation. If <b>-p</b> is specified, a prompt of the following format shall be written (in the POSIX locale):</p><pre><tt>"?..."</tt></pre>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -