📄 xargs.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>xargs</title></head><body bgcolor=white><center><font size=2>The Single UNIX ® Specification, Version 2<br>Copyright © 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_001_014_2923"> </a>NAME</h4><blockquote>xargs - construct argument lists and invoke utility</blockquote><h4><a name = "tag_001_014_2924"> </a>SYNOPSIS</h4><blockquote><pre><code>xargs <b>[</b>-t<b>][</b>-p<b>][</b>-e<b>[</b><i>eofstr</i><b>]][</b>-E <i>eofstr</i><b>][</b>-I <i>replstr</i><b>][</b>-i<b>[</b><i>replstr</i><b>]][</b>-L <i>number</i><b>][</b>-l<b>[</b><i>number</i><b>]][</b>-n <i>number </i><b>[</b>-x<b>]][</b>-s <i>size</i><b>][</b><i>utility </i><b>[</b><i>argument</i>...<b>]]</b></code></pre></blockquote><h4><a name = "tag_001_014_2925"> </a>DESCRIPTION</h4><blockquote>The<i>xargs</i>utility constructs a command line consisting of the<i>utility</i>and<i>argument</i>operands specified followed by as manyarguments read in sequence from standard input as will fit inlength and number constraints specified by the options.The<i>xargs</i>utility then invokes the constructed command line andwaits for its completion.This sequence is repeated until an end-of-filecondition is detected on standard input or an invocationof a constructed command line returnsan exit status of 255.<p>Arguments in the standard input must be separated by unquotedblank characters,or unescapedblank charactersornewline characters.A string of zero or more non-double-quote( )andnon-newlinecharacters can be quoted by enclosing them in double-quotes.A string of zero or more non-apostrophe(')andnon-newlinecharacters can be quoted by enclosing them in apostrophes.Any unquoted character can be escaped by preceding it with a backslash.The<i>utility</i>will be executed one or more timesuntil the end-of-file is reached.The results are unspecified if the utility named by<i>utility</i>attempts to read from its standard input.<p>The generated command line length will be the sum of the size in bytes ofthe utility name and each argument treated as strings, including a nullbyte terminator for each of these strings.The<i>xargs</i>utility will limit the command line length such thatwhen the command line is invoked, the combined argument andenvironment lists (see the<i>exec</i>family of functions in the <b>XSH</b> specification)will not exceed{ARG_MAX}-2048bytes.Within this constraint, if neither the<b>-n</b>nor the<b>-s</b>option is specified,the default command line length will be at least{LINE_MAX}.</blockquote><h4><a name = "tag_001_014_2926"> </a>OPTIONS</h4><blockquote>The<i>xargs</i>utility supports the <b>XBD</b> specification, <a href="../xbd/utilconv.html#usg"><b>Utility Syntax Guidelines</b> </a> ,except that the<b>-e</b>,<b>-i</b>and<b>-l</b>take optional option-arguments that cannot be separate arguments.<p>The following options are supported:<dl compact><dt><b>-e[</b><i>eofstr</i><b>]</b><dd>Use<i>eofstr</i>as the logical end-of-file string.Underscore(_)is assumed for the logical EOF string if neither<b>-e</b>nor<b>-E</b>is used.When the<b>-eofstr</b>option-argument is omitted, the logical EOF stringcapability is disabled and underscores are taken literally.The<i>xargs</i>utilityreads standard input until either end-of-file orthe logical EOF string is encountered.<dt><b>-E </b><i>eofstr</i><dd>Specify a logical end-of-file string to replace the default underscore.The<i>xargs</i>utilityreads standard input until either end-of-file orthe logical EOF string is encountered.<dt><b>-I </b><i>replstr</i><dd>Insert mode:<i>utility</i>will be executed for each line from standard input,taking the entire line as a single argument, inserting it in<i>argument</i>sfor each occurrence of<i>replstr</i>.A maximum of five arguments in<i>argument</i>scan each contain one or more instances of<i>replstr</i>.Anyblank charactersat the beginning of each line are ignored.Constructed arguments cannot grow larger than255 bytes.Option<b>-x</b>is forced on.The<b>-I</b>and<b>-i</b>options are mutually exclusive; the last one specifiedtakes effect.<dt><b>-i[</b><i>replstr</i><b>]</b><dd>This option is equivalent to<b>-I</b> <i>replstr</i>.The string <b>{}</b> is assumed for<i>replstr</i>if the option-argument is omitted.<dt><b>-L </b><i>number</i><dd>The<i>utility</i>will be executed for each non-empty<i>number</i>lines of arguments from standard input.The last invocation of<i>utility</i>will be with fewer lines of arguments if fewer than<i>number</i>remain.A line is considered to end with the firstnewline characterunless the last character of the line is ablank character;a trailingblank charactersignals continuation to the next non-empty line, inclusive.The<b>-L</b>,<b>-l</b>and<b>-n</b>options are mutually exclusive; the last one specifiedtakes effect.<dt><b>-l[</b><i>number</i><b>]</b><dd>(The letter ell.)This option is equivalent to<b>-L</b> <i>number</i>.If<i>number</i>is omitted, 1 is assumed.Option<b>-x</b>is forced on.<dt><b>-n </b><i>number</i><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 will be used if:<ul><li>The command line length accumulated exceeds the size specifiedby the<b>-s</b>option (or{LINE_MAX}if there is no<b>-s</b>option).<li>The last iteration has fewer than<i>number</i>,but not zero, operands remaining.</ul><dt><b>-p</b><dd>Prompt mode: the user is asked whether to execute<i>utility</i>at each invocation.Trace mode(<b>-t</b>)is turned on to write the command instance to be executed,followed by a prompt to standard error.An affirmative response read from<b>/dev/tty</b>will execute the command; otherwise,that particular invocation of<i>utility</i>is skipped.<dt><b>-s </b><i>size</i><dd>Invoke<i>utility</i>using as many standard input arguments as possible yielding acommand line length less than<i>size</i>(a positive decimal integer)bytes.Fewer arguments will be used if:<ul><li>The total number of arguments exceeds that specified by the<b>-n</b>option.<li>The total number of lines exceeds that specified by the<b>-L</b>option.<li>End-of-file is encountered on standard input before<i>size</i>bytes are accumulated.</ul>Values of<i>size</i>up to at least{LINE_MAX}bytes are supported,provided that the constraints specified in the DESCRIPTION sectionare met.It is not considered an error if a valuelarger than that supported by the implementation or exceedingthe constraints specified in the DESCRIPTION section is given;<i>xargs</i>will use the largest value it supports within the constraints.<dt><b>-t</b><dd>Enable trace mode.Each generated command line will be written to standard errorjust prior to invocation.<dt><b>-x</b><dd>Terminate if a command line containing<i>number</i>arguments (see the<b>-n</b>option above)or<i>number</i>lines (see the<b>-L</b>option above)will not fit in the implied or specified size (see the<b>-s</b>option above).</dl></blockquote><h4><a name = "tag_001_014_2927"> </a>OPERANDS</h4><blockquote>The following operands are supported:<dl compact><dt><i>utility</i><dd>The name of the utility to be invoked,found by search path using the<i>PATH</i>environment variable, described inthe <b>XBD</b> specification, <a href="../xbd/envvar.html"><b>Environment Variables</b> </a> .If<i>utility</i>is omitted,the default is the<i><a href="echo.html">echo</a></i>utility.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -