xargs - Construct argument lists and invoke utility
Synopsis
xargs [-t]
[-e[eofstring]] [-E eofstring]
[-l[number ]] [-L number]
[-n number [-x]]
[-s size] [utility
[arguments ...]]
Description
The xargs utility reads space, tab, newline and
end-of-file delimited arguments from the standard input
and runs the specified utility with them as arguments.
The utility and any arguments specified on the
command line are given to the utility upon each
invocation, followed by some number of the arguments read
from standard input. The utility is repeatedly run until
standard input is exhausted.
Spaces, tabs and newlines may be embedded in arguments using
single (') or double (") quotation marks or backslashes (\). Single quotation marks
escape all non-single quotation mark characters, excluding newlines, up to
the matching single quotation marks. Double quotation marks escape all non-double
quotation mark characters, excluding newlines, up to the matching double
quotation marks. Any single character, including newlines, may be escaped by
a backslash.
If no utility is specified, echo is
used by default.
Undefined behavior may occur if utility reads from the
standard input.
The xargs utility exits immediately (without
processing any further input) if a command line cannot be
assembled, utility cannot be invoked, an invocation of the
utility is ended by a signal, or an invocation of the
utility exits with a value of 255.
Options
-
-E eofstring
- Specify a logical end-of-file string.
xargs reads standard input until either end-of-file or the logical
end-of-file string is encountered.
- -e[eofstring]
- This option is equivalent to the -E option. If eofstring is not
specified, the default value is _ (a single underscore).
- -L number
- Run utility for each non-empty number lines of arguments read from
standard input. The last invocation of utility will be with
fewer lines of arguments if fewer than number remain.
A line is considered to end with the first newline character unless the
last character of the line is a blank character. A trailing blank character signals
continuation to the next non-empty line, inclusive. The -L and
-n options are mutually exclusive. The last one
specified takes effect.
- -l[ number ]
- This option is equivalent to the -L option.
If number is not specified, the default value is 1.
- -n number
- Set the maximum number of arguments read from
standard input for each invocation of the utility. An
invocation of utility will use less than number
standard input arguments if the number of bytes accumulated (see
the -s option) exceeds the specified size or there
are fewer than number arguments remaining for the last
invocation of utility. The maximum number of arguments
i5/OS(TM) can pass to a program is 255. The default value for
number is 250. The -n and
-L options are mutually exclusive. The last one
specified takes effect.
- -s size
- Set the maximum number of bytes for the command line length
provided to utility. The sum of the length of the utility
name and the arguments passed to utility (including NULL
terminators) will be less than or equal to size. The
default value for size is 16 252 928 bytes.
- -t
- Turn on trace mode. The command to be run is written to standard error
immediately before it is run.
- -x
- Force xargs to end immediately if a command
line containing number arguments will not fit in the
specified (or default) command line length.
Exit Status
- 0 when all invocations of utility returned exit status 0.
- 1-125 when at least one invocation of utility returned a
non-zero exit status or there was an error.
- 126 when utility was found but could not be invoked.
- 127 when utility cannot be found.
- >128 when utility was ended by a signal. The value is 128 plus the signal number.
Related information