Open System Services Shell and Utilities Reference Manual (G06.25+, H06.03+)
Table Of Contents
User Commands (v - z) xargs(1)
The -l, -L, and -n flags are mutually exclusive; the last one of these flags specified
takes effect.
-p Asks whether or not to run the command string. Trace mode (-t) is turned on to write
the command instance to be executed, followed by a prompt to standard error (?...).
An affirmative response read from /dev/tty executes the command. Any other response
causes xargs to skip that particular invocation of the command string. You are asked
about each invocation.
-r This flag is the same as -I {}.
The -i, -I, and -r flags are mutually exclusive; the last one of these flags specified takes
effect.
-s size Invokes the specified command using as many standard input arguments as possible,
yielding a command line length less than size (a positive decimal integer) bytes. Fewer
arguments are used if any of the following conditions is true:
• The total number of arguments exceeds that specified by -n.
• The total number of lines exceeds that specified by -L.
• End-of-File is encountered on standard input before size bytes are accumu-
lated.
Note that the character count for size includes one extra character for each argument
and the number of characters in the command name. Values of size up to at least
LINE_MAX bytes are supported.
-t Echoes the command string and each constructed argument list to file descriptor 2 (usu-
ally standard error).
-x Stops running xargs if any argument list is greater than the number of characters
specified by the -s size flag. This flag is turned on if you specify either the -I or -L
flags. If you do not specify -I, -L,or-n, the total length of all arguments must be
within the length limit.
DESCRIPTION
The xargs command runs the command string as many times as necessary to process all input
arguments. The default command string is /usr/bin/echo.
Arguments read from standard input are character strings delimited by one or more spaces, tabs,
or newline characters. You can embed a space or a tab in arguments by preceding it with a \
(backslash) or by quoting it. The xargs command reads characters enclosed in single or double
quotes as literals and removes the delimiting quotes. It always discards empty lines.
The xargs command ends if it cannot run the command string or if it receives an exit code of
255. When the command string calls a shell procedure, the shell procedure should explicitly exit
with an appropriate value to avoid accidentally returning 255. (See the sh command.)
The LC_MESSAGES variables determines the locale’s equivalent of y and n (for yes/no
queries).
EXAMPLES
1. To use a command on files whose names are listed in a file, use a command line similar
to the following:
xargs ls -l < cfiles
If cfiles contains the text, enter:
527188-003 Hewlett-Packard Company 10−33