{"id":6275,"date":"2022-12-20T18:58:05","date_gmt":"2022-12-20T21:58:05","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/xargs-man1p\/"},"modified":"2022-12-20T18:58:05","modified_gmt":"2022-12-20T21:58:05","slug":"xargs-man1p","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/xargs-man1p\/","title":{"rendered":"XARGS (man1p)"},"content":{"rendered":"<h1 align=\"center\">XARGS<\/h1>\n<p> <a href=\"#PROLOG\">PROLOG<\/a><br \/> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#OPTIONS\">OPTIONS<\/a><br \/> <a href=\"#OPERANDS\">OPERANDS<\/a><br \/> <a href=\"#STDIN\">STDIN<\/a><br \/> <a href=\"#INPUT FILES\">INPUT FILES<\/a><br \/> <a href=\"#ENVIRONMENT VARIABLES\">ENVIRONMENT VARIABLES<\/a><br \/> <a href=\"#ASYNCHRONOUS EVENTS\">ASYNCHRONOUS EVENTS<\/a><br \/> <a href=\"#STDOUT\">STDOUT<\/a><br \/> <a href=\"#STDERR\">STDERR<\/a><br \/> <a href=\"#OUTPUT FILES\">OUTPUT FILES<\/a><br \/> <a href=\"#EXTENDED DESCRIPTION\">EXTENDED DESCRIPTION<\/a><br \/> <a href=\"#EXIT STATUS\">EXIT STATUS<\/a><br \/> <a href=\"#CONSEQUENCES OF ERRORS\">CONSEQUENCES OF ERRORS<\/a><br \/> <a href=\"#APPLICATION USAGE\">APPLICATION USAGE<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#RATIONALE\">RATIONALE<\/a><br \/> <a href=\"#FUTURE DIRECTIONS\">FUTURE DIRECTIONS<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a> <\/p>\n<hr>\n<h2>PROLOG <a name=\"PROLOG\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This manual page is part of the POSIX Programmer\u2019s Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">xargs \u2014 construct argument lists and invoke utility<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">xargs <b>[<\/b>-ptx<b>] [<\/b>-E <i>eofstr<\/i><b>] [<\/b>-I <i>replstr<\/i>|-L <i>number<\/i>|-n <i>number<\/i><b>] <br \/> [<\/b>-s <i>size<\/i><b>] [<\/b><i>utility<\/i> <b>[<\/b><i>argument<\/i>&#8230;<b>]]<\/b><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>xargs<\/i> utility shall construct a command line consisting of the <i>utility<\/i> and <i>argument<\/i> operands specified followed by as many arguments read in sequence from standard input as fit in length and number constraints specified by the options. The <i>xargs<\/i> utility shall then invoke the constructed command line and wait for its completion. This sequence shall be repeated until one of the following occurs:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>An end-of-file condition is detected on standard input.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>An argument consisting of just the logical end-of-file string (see the <b>\u2212E<\/b> <i>eofstr<\/i> option) is found on standard input after double-quote processing, <apostrophe> processing, and <backslash>-escape processing (see next paragraph). All arguments up to but not including the argument consisting of just the logical end-of-file string shall be used as arguments in constructed command lines.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>An invocation of a constructed command line returns an exit status of 255.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">The application shall ensure that arguments in the standard input are separated by unquoted <blank> characters, unescaped <blank> characters, or <newline> characters. A string of zero or more non-double-quote (<b>\u2019&#8221;\u2019<\/b>) characters and non-<newline> characters can be quoted by enclosing them in double-quotes. A string of zero or more non-<apostrophe> (<b>\u2019&#8217;\u2019<\/b>) characters and non-<newline> characters can be quoted by enclosing them in <apostrophe> characters. Any unquoted character can be escaped by preceding it with a <backslash>. The utility named by <i>utility<\/i> shall be executed one or more times until the end-of-file is reached or the logical end-of file string is found. The results are unspecified if the utility named by <i>utility<\/i> attempts to read from its standard input.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The generated command line length shall be the sum of the size in bytes of the utility name and each argument treated as strings, including a null byte terminator for each of these strings. The <i>xargs<\/i> utility shall limit the command line length such that when the command line is invoked, the combined argument and environment lists (see the <i>exec<\/i> family of functions in the System Interfaces volume of POSIX.1-2017) shall not exceed {ARG_MAX}\u22122048 bytes. Within this constraint, if neither the <b>\u2212n<\/b> nor the <b>\u2212s<\/b> option is specified, the default command line length shall be at least {LINE_MAX}.<\/p>\n<h2>OPTIONS <a name=\"OPTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>xargs<\/i> utility shall conform to the Base Definitions volume of POSIX.1-2017, <i>Section 12.2<\/i>, <i>Utility Syntax Guidelines<\/i>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The following options shall be supported:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"14%\">\n<p style=\"margin-top: 1em\"><b>\u2212E\u00a0<\/b><i>eofstr<\/i><\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"74%\">\n<p style=\"margin-top: 1em\">Use <i>eofstr<\/i> as the logical end-of-file string. If <b>\u2212E<\/b> is not specified, it is unspecified whether the logical end-of-file string is the <underscore> character (<b>\u2019_\u2019<\/b>) 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 be taken literally.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%;\"><b>\u2212I\u00a0<\/b><i>replstr<\/i><\/p>\n<p style=\"margin-left:26%;\">Insert mode: <i>utility<\/i> is executed for each logical line from standard input. Arguments in the standard input shall be separated only by unescaped <newline> characters, not by <blank> characters. Any unquoted unescaped <blank> characters at the beginning of each line shall be ignored. The resulting argument shall be inserted in <i>arguments<\/i> in place of each occurrence of <i>replstr<\/i>. At least five arguments in <i>arguments<\/i> can each contain one or more instances of <i>replstr<\/i>. Each of these constructed arguments cannot grow larger than an implementation-defined limit greater than or equal to 255 bytes. Option <b>\u2212x<\/b> shall be forced on.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"14%\">\n<p><b>\u2212L\u00a0<\/b><i>number<\/i><\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"74%\">\n<p>The <i>utility<\/i> shall be executed for each non-empty <i>number<\/i> lines of arguments from standard input. The last invocation of <i>utility<\/i> shall be with fewer lines of arguments if fewer than <i>number<\/i> remain. A line is considered to end with the first <newline> unless the last character of the line is an unescaped <blank>; a trailing unescaped <blank> signals continuation to the next non-empty line, inclusive.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"14%\">\n<p><b>\u2212n\u00a0<\/b><i>number<\/i><\/p>\n<\/td>\n<td width=\"1%\"><\/td>\n<td width=\"74%\">\n<p>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:<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:26%;\">*<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"18%\"><\/td>\n<td width=\"3%\"><\/td>\n<td width=\"68%\">\n<p style=\"margin-top: 1em\">The command line length accumulated exceeds the size specified by the <b>\u2212s<\/b> option (or {LINE_MAX} if there is no <b>\u2212s<\/b> option).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"18%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"68%\">\n<p>The last iteration has fewer than <i>number<\/i>, but not zero, operands remaining.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"18%\">\n<p><b>\u2212p<\/b><\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"68%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:26%; margin-top: 1em\">Prompt mode: the user is asked whether to execute <i>utility<\/i> at each invocation. Trace mode (<b>\u2212t<\/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> shall execute the command; otherwise, that particular invocation of <i>utility<\/i> shall be skipped.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p style=\"margin-top: 1em\"><b>\u2212s\u00a0<\/b><i>size<\/i><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"74%\">\n<p style=\"margin-top: 1em\">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:<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:26%;\">*<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"28%\"><\/td>\n<td width=\"1%\"><\/td>\n<td width=\"3%\"><\/td>\n<td width=\"68%\">\n<p style=\"margin-top: 1em\">The total number of arguments exceeds that specified by the <b>\u2212n<\/b> option.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"28%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"68%\">\n<p>The total number of lines exceeds that specified by the <b>\u2212L<\/b> option.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"28%\"><\/td>\n<td width=\"1%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"68%\">\n<p>End-of-file is encountered on standard input before <i>size<\/i> bytes are accumulated.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:26%; margin-top: 1em\">Values of <i>size<\/i> up to at least {LINE_MAX} bytes shall be supported, provided that the constraints specified in the DESCRIPTION are met. It shall not be considered an error if a value larger than that supported by the implementation or exceeding the constraints specified in the DESCRIPTION is given; <i>xargs<\/i> shall use the largest value it supports within the constraints.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\"><b>\u2212t<\/b><\/p>\n<\/td>\n<td width=\"12%\"><\/td>\n<td width=\"74%\">\n<p style=\"margin-top: 1em\">Enable trace mode. Each generated command line shall be written to standard error just prior to invocation.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"3%\">\n<p><b>\u2212x<\/b><\/p>\n<\/td>\n<td width=\"12%\"><\/td>\n<td width=\"74%\">\n<p>Terminate if a constructed command line will not fit in the implied or specified size (see the <b>\u2212s<\/b> option above).<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>OPERANDS <a name=\"OPERANDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The following operands shall be supported:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"12%\">\n<p style=\"margin-top: 1em\"><i>utility<\/i><\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"74%\">\n<p style=\"margin-top: 1em\">The name of the utility to be invoked, found by search path using the <i>PATH<\/i> environment variable, described in the Base Definitions volume of POSIX.1-2017, <i>Chapter 8<\/i>, <i>Environment Variables<\/i>. If <i>utility<\/i> is omitted, the default shall be the <i>echo<\/i> utility. If the <i>utility<\/i> operand names any of the special built-in utilities in <i>Section 2.14<\/i>, <i>Special Built-In Utilities<\/i>, the results are undefined.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"12%\">\n<p><i>argument<\/i><\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"74%\">\n<p>An initial option or operand for the invocation of <i>utility<\/i>.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>STDIN <a name=\"STDIN\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The standard input shall be a text file. The results are unspecified if an end-of-file condition is detected immediately following an escaped <newline>.<\/p>\n<h2>INPUT FILES <a name=\"INPUT FILES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The file <b>\/dev\/tty<\/b> shall be used to read responses required by the <b>\u2212p<\/b> option.<\/p>\n<h2>ENVIRONMENT VARIABLES <a name=\"ENVIRONMENT VARIABLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The following environment variables shall affect the execution of <i>xargs<\/i>:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p style=\"margin-top: 1em\"><i>LANG<\/i><\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"74%\">\n<p style=\"margin-top: 1em\">Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1-2017, <i>Section 8.2<\/i>, <i>Internationalization Variables<\/i> for the precedence of internationalization variables used to determine the values of locale categories.)<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"9%\">\n<p><i>LC_ALL<\/i><\/p>\n<\/td>\n<td width=\"6%\"><\/td>\n<td width=\"74%\">\n<p>If set to a non-empty string value, override the values of all the other internationalization variables.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%;\"><i>LC_COLLATE<\/i><\/p>\n<p style=\"margin-left:26%;\">Determine the locale for the behavior of ranges, equivalence classes, and multi-character collating elements used in the extended regular expression defined for the <b>yesexpr<\/b> locale keyword in the <i>LC_MESSAGES<\/i> category.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"12%\">\n<p><i>LC_CTYPE<\/i><\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"74%\">\n<p>Determine 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 and input files) and the behavior of character classes used in the extended regular expression defined for the <b>yesexpr<\/b> locale keyword in the <i>LC_MESSAGES<\/i> category.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%;\"><i>LC_MESSAGES<\/i><\/p>\n<p style=\"margin-left:26%;\">Determine the locale used to process affirmative responses, and the locale used to affect the format and contents of diagnostic messages and prompts written to standard error.<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p><i>NLSPATH<\/i><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"74%\">\n<p>Determine the location of message catalogs for the processing of <i>LC_MESSAGES<\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"11%\">\n<p><i>PATH<\/i><\/p>\n<\/td>\n<td width=\"4%\"><\/td>\n<td width=\"74%\">\n<p>Determine the location of <i>utility<\/i>, as described in the Base Definitions volume of POSIX.1-2017, <i>Chapter 8<\/i>, <i>Environment Variables<\/i>.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>ASYNCHRONOUS EVENTS <a name=\"ASYNCHRONOUS EVENTS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Default.<\/p>\n<h2>STDOUT <a name=\"STDOUT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Not used.<\/p>\n<h2>STDERR <a name=\"STDERR\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The standard error shall be used for diagnostic messages and the <b>\u2212t<\/b> and <b>\u2212p<\/b> options. If the <b>\u2212t<\/b> option is specified, the <i>utility<\/i> and its constructed argument list shall be written to standard error, as it will be invoked, prior to invocation. If <b>\u2212p<\/b> is specified, a prompt of the following format shall be written (in the POSIX locale):<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">&#8220;?&#8230;&#8221;<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">at the end of the line of the output from <b>\u2212t<\/b>.<\/p>\n<h2>OUTPUT FILES <a name=\"OUTPUT FILES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>EXTENDED DESCRIPTION <a name=\"EXTENDED DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>EXIT STATUS <a name=\"EXIT STATUS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The following exit values shall be returned:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"7%\">\n<p style=\"margin-top: 1em\">0<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"77%\">\n<p style=\"margin-top: 1em\">All invocations of <i>utility<\/i> returned exit status zero.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"7%\">\n<p>1-125<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"77%\">\n<p>A command line meeting the specified requirements could not be assembled, one or more of the invocations of <i>utility<\/i> returned a non-zero exit status, or some other error occurred.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"7%\">\n<p>126<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"77%\">\n<p>The utility specified by <i>utility<\/i> was found but could not be invoked.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"7%\">\n<p>127<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"77%\">\n<p>The utility specified by <i>utility<\/i> could not be found.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<h2>CONSEQUENCES OF ERRORS <a name=\"CONSEQUENCES OF ERRORS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">If a command line meeting the specified requirements cannot be assembled, the utility cannot be invoked, an invocation of the utility is terminated by a signal, or an invocation of the utility exits with exit status 255, the <i>xargs<\/i> utility shall write a diagnostic message and exit without processing any remaining input.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>The following sections are informative.<\/i><\/p>\n<h2>APPLICATION USAGE <a name=\"APPLICATION USAGE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The 255 exit status allows a utility being used by <i>xargs<\/i> to tell <i>xargs<\/i> to terminate if it knows no further invocations using the current data stream will succeed. Thus, <i>utility<\/i> should explicitly <i>exit<\/i> with an appropriate value to avoid accidentally returning with 255.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Note that since input is parsed as lines, <blank> characters separate arguments, and <backslash>, <apostrophe>, and double-quote characters are used for quoting, if <i>xargs<\/i> is used to bundle the output of commands like <i>find dir<\/i> <b>\u2212print<\/b> or <i>ls<\/i> into commands to be executed, unexpected results are likely if any filenames contain <blank>, <newline>, or quoting characters. This can be solved by using find to call a script that converts each file found into a quoted string that is then piped to <i>xargs<\/i>, but in most cases it is preferable just to have <i>find<\/i> do the argument aggregation itself by using <b>\u2212exec<\/b> with a <b>\u2019+\u2019<\/b> terminator instead of <b>\u2019;\u2019<\/b>. Note that the quoting rules used by <i>xargs<\/i> are not the same as in the shell. They were not made consistent here because existing applications depend on the current rules. An easy (but inefficient) method that can be used to transform input consisting of one argument per line into a quoted form that <i>xargs<\/i> interprets correctly is to precede each non-<newline> character with a <backslash>. More efficient alternatives are shown in Example 2 and Example 5 below.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">On implementations with a large value for {ARG_MAX}, <i>xargs<\/i> may produce command lines longer than {LINE_MAX}. For invocation of utilities, this is not a problem. If <i>xargs<\/i> is being used to create a text file, users should explicitly set the maximum command line length with the <b>\u2212s<\/b> option.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>command<\/i>, <i>env<\/i>, <i>nice<\/i>, <i>nohup<\/i>, <i>time<\/i>, and <i>xargs<\/i> utilities have been specified to use exit code 127 if an error occurs so that applications can distinguish \u2018\u2018failure to find a utility\u2019\u2019 from \u2018\u2018invoked utility exited with an error indication\u2019\u2019. The value 127 was chosen because it is not commonly used for other meanings; most utilities use small values for \u2018\u2018normal error conditions\u2019\u2019 and the values above 128 can be confused with termination due to receipt of a signal. The value 126 was chosen in a similar manner to indicate that the utility could be found, but not invoked. Some scripts produce meaningful error messages differentiating the 126 and 127 cases. The distinction between exit codes 126 and 127 is based on KornShell practice that uses 127 when all attempts to <i>exec<\/i> the utility fail with <b>[ENOENT]<\/b>, and uses 126 when any attempt to <i>exec<\/i> the utility fails for any other reason.<\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\">1.<\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"83%\">\n<p style=\"margin-top: 1em\">The following command combines the output of the parenthesized commands (minus the <apostrophe> characters) onto one line, which is then appended to the file log. It assumes that the expansion of <b>&#8220;$0<\/b>$*&#8221; does not include any <apostrophe> or <newline> characters.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:23%; margin-top: 1em\">(logname; date; printf &#8220;&#8216;%s&#8217;n$0 $*&#8221;) | xargs -E &#8220;&#8221; >>log<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\">2.<\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"83%\">\n<p style=\"margin-top: 1em\">The following command invokes <i>diff<\/i> with successive pairs of arguments originally typed as command line arguments. It assumes there are no embedded <newline> characters in the elements of the original argument list.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:23%; margin-top: 1em\">printf &#8220;%sn$@&#8221; | sed &#8216;s\/[^[:alnum:]]\/\\&#038;\/g&#8217; | <br \/> xargs -E &#8220;&#8221; -n 2 -x diff<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\">3.<\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"83%\">\n<p style=\"margin-top: 1em\">In the following commands, the user is asked which files in the current directory (excluding dotfiles) are to be archived. The files are archived into <b>arch<\/b>; <i>a<\/i>, one at a time or <i>b<\/i>, many at a time. The commands assume that no filenames contain <blank>, <newline>, <backslash>, <apostrophe>, or double-quote characters.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:23%; margin-top: 1em\">a. ls | xargs -E &#8220;&#8221; -p -L 1 ar -r arch<\/p>\n<p style=\"margin-left:23%; margin-top: 1em\">b. ls | xargs -E &#8220;&#8221; -p -L 1 | xargs -E &#8220;&#8221; ar -r arch<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\">4.<\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"83%\">\n<p style=\"margin-top: 1em\">The following command invokes <i>command1<\/i> one or more times with multiple arguments, stopping if an invocation of <i>command1<\/i> has a non-zero exit status.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:23%; margin-top: 1em\">xargs -E &#8220;&#8221; sh -c &#8216;command1 &#8220;$@&#8221; || exit 255&#8217; sh < xargs_input<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\">5.<\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"83%\">\n<p style=\"margin-top: 1em\">On XSI-conformant systems, the following command moves all files from directory <b>$1<\/b> to directory <b>$2<\/b>, and echoes each move command just before doing it. It assumes no filenames contain <newline> characters and that neither <b>$1<\/b> nor <b>$2<\/b> contains the sequence <b>&#8220;{}&#8221;<\/b>.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:23%; margin-top: 1em\">ls -A &#8220;$1&#8221; | sed -e &#8216;s\/&#8221;\/&#8221;\\&#8221;&#8221;\/g&#8217; -e &#8216;s\/.*\/&#8221;&#038;&#8221;\/&#8217; | <br \/> xargs -E &#8220;&#8221; -I {} -t mv &#8220;$1&#8243;\/{} &#8220;$2&#8243;\/{}<\/p>\n<h2>RATIONALE <a name=\"RATIONALE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The <i>xargs<\/i> utility was usually found only in System V-based systems; BSD systems included an <i>apply<\/i> utility that provided functionality similar to <i>xargs<\/i> <b>\u2212n<\/b> <i>number<\/i>. The SVID lists <i>xargs<\/i> as a software development extension. This volume of POSIX.1-2017 does not share the view that it is used only for development, and therefore it is not optional.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The classic application of the <i>xargs<\/i> utility is in conjunction with the <i>find<\/i> utility to reduce the number of processes launched by a simplistic use of the <i>find<\/i> <b>\u2212exec<\/b> combination. The <i>xargs<\/i> utility is also used to enforce an upper limit on memory required to launch a process. With this basis in mind, this volume of POSIX.1-2017 selected only the minimal features required.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Although the 255 exit status is mostly an accident of historical implementations, it allows a utility being used by <i>xargs<\/i> to tell <i>xargs<\/i> to terminate if it knows no further invocations using the current data stream shall succeed. Any non-zero exit status from a utility falls into the 1-125 range when <i>xargs<\/i> exits. There is no statement of how the various non-zero utility exit status codes are accumulated by <i>xargs<\/i>. The value could be the addition of all codes, their highest value, the last one received, or a single value such as 1. Since no algorithm is arguably better than the others, and since many of the standard utilities say little more (portably) than \u2018\u2018pass\/fail\u2019\u2019, no new algorithm was invented.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Several other <i>xargs<\/i> options were removed because simple alternatives already exist within this volume of POSIX.1-2017. For example, the <b>\u2212i<\/b> <i>replstr<\/i> option can be just as efficiently performed using a shell <b>for<\/b> loop. Since <i>xargs<\/i> calls an <i>exec<\/i> function with each input line, the <b>\u2212i<\/b> option does not usually exploit the grouping capabilities of <i>xargs<\/i>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The requirement that <i>xargs<\/i> never produces command lines such that invocation of <i>utility<\/i> is within 2048 bytes of hitting the POSIX <i>exec<\/i> {ARG_MAX} limitations is intended to guarantee that the invoked utility has room to modify its environment variables and command line arguments and still be able to invoke another utility. Note that the minimum {ARG_MAX} allowed by the System Interfaces volume of POSIX.1-2017 is 4096 bytes and the minimum value allowed by this volume of POSIX.1-2017 is 2048 bytes; therefore, the 2048 bytes difference seems reasonable. Note, however, that <i>xargs<\/i> may never be able to invoke a utility if the environment passed in to <i>xargs<\/i> comes close to using {ARG_MAX} bytes.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The version of <i>xargs<\/i> required by this volume of POSIX.1-2017 is required to wait for the completion of the invoked command before invoking another command. This was done because historical scripts using <i>xargs<\/i> assumed sequential execution. Implementations wanting to provide parallel operation of the invoked utilities are encouraged to add an option enabling parallel invocation, but should still wait for termination of all of the children before <i>xargs<\/i> terminates normally.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>\u2212e<\/b> option was omitted from the ISO\u00a0POSIX-2:1993 standard in the belief that the <i>eofstr<\/i> option-argument was recognized only when it was on a line by itself and before quote and escape processing were performed, and that the logical end-of-file processing was only enabled if a <b>\u2212e<\/b> option was specified. In that case, a simple <i>sed<\/i> script could be used to duplicate the <b>\u2212e<\/b> functionality. Further investigation revealed that:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p style=\"margin-top: 1em\">*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p style=\"margin-top: 1em\">The logical end-of-file string was checked for after quote and escape processing, making a <i>sed<\/i> script that provided equivalent functionality much more difficult to write.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"2%\">\n<p>*<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"83%\">\n<p>The default was to perform logical end-of-file processing with an <underscore> as the logical end-of-file string.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%; margin-top: 1em\">To correct this misunderstanding, the <b>\u2212E<\/b> <i>eofstr<\/i> option was adopted from the X\/Open Portability Guide. Users should note that the description of the <b>\u2212E<\/b> option matches historical documentation of the <b>\u2212e<\/b> option (which was not adopted because it did not support the Utility Syntax Guidelines), by saying that if <i>eofstr<\/i> is the null string, logical end-of-file processing is disabled. Historical implementations of <i>xargs<\/i> actually did not disable logical end-of-file processing; they treated a null argument found in the input as a logical end-of-file string. (A null <i>string<\/i> argument could be generated using single or double-quotes (<b>\u2019\u2019<\/b> or <b>&#8220;&#8221;<\/b>). Since this behavior was not documented historically, it is considered to be a bug.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The <b>\u2212I<\/b>, <b>\u2212L<\/b>, and <b>\u2212n<\/b> options are mutually-exclusive. Some implementations use the last one specified if more than one is given on a command line; other implementations treat combinations of the options in different ways.<\/p>\n<h2>FUTURE DIRECTIONS <a name=\"FUTURE DIRECTIONS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">None.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>Chapter 2<\/i>, <i>Shell Command Language<\/i>, <i>diff<\/i>, <i>echo<\/i>, <i>find<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The Base Definitions volume of POSIX.1-2017, <i>Chapter 8<\/i>, <i>Environment Variables<\/i>, <i>Section 12.2<\/i>, <i>Utility Syntax Guidelines<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The System Interfaces volume of POSIX.1-2017, <i>exec<\/i><\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology &#8212; Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http:\/\/www.opengroup.org\/unix\/online.html .<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https:\/\/www.kernel.org\/doc\/man-pages\/reporting_bugs.html .<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  xargs \u2014 construct argument lists and invoke utility <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3782,1],"tags":[2511,2885],"class_list":["post-6275","post","type-post","status-publish","format-standard","hentry","category-1p-posix-comandos-generales","category-sin-categoria","tag-man1p","tag-xargs"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=6275"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/6275\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=6275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=6275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=6275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}