HP-UX Reference (11i v1 05/09) - 1 User Commands N-Z (vol 2)
x
xargs(1) xargs(1)
-p Prompt mode: The user is asked whether to execute command prior to each invoca-
tion. Trace mode (
-t) is turned on to print the command instance to be executed, fol-
lowed by a
?... prompt. An affirmative reply (by default, an affirmative reply is
y
optionally followed by anything) executes the command; anything else, including
pressing Return, skips that particular invocation of command.
-x Causes xargs to terminate if any argument list would be greater than size bytes.
-x
is forced by the options -i,
-I, -l, and -L. When none of the options -i, -I, -l,
-L,or -n is coded, the total length of all arguments must be within the size limit.
-e[ eofstr ] eofstr is taken as the logical end-of-file string. Underscore (
_) is assumed for the logi-
cal
EOF string if neither -e nor -E
is used. The value -e with eofstr given as the
empty string ( "" ) turns off the logical
EOF string capability (underscore is taken
literally). xargs reads standard input until either end-of-file or the logical
EOF string
is encountered.
-E eofstr Specify a logical end-of-file string to replace the default underscore (
_) character.
Equivalent to the
-e option above.
xargs terminates if it receives a return code of −1 from command or if it cannot execute command. When
command is a shell program, it should explicitly
exit (see sh(1)) with an appropriate value to avoid
accidentally returning with −1.
RETURN VALUE
xargs exits with one of the following values:
0 All invocations of command completed successfully.
1-125
One or more invocations of command did not complete successfully.
126 The command specified was found but could not be invoked.
127 The command specified could not be found.
EXTERNAL INFLUENCES
Environment Variables
LC_CTYPE determines the space characters and the interpretation of text as single- and/or multi-byte
characters.
LC_MESSAGES determines the language in which messages are displayed, and the local language
equivalent of an affirmative reply when the -p prompt option is specified.
If LC_CTYPE or LC_MESSAGES is not specified in the environment or is set to the empty string, the
value of LANG is used as a default for each unspecified or empty variable. If
LANG is not specified or is
set to the empty string, a default of "C" (see lang(5)) is used instead of
LANG
.
If any internationalization variable contains an invalid setting,
xargs behaves as if all internationaliza-
tion variables are set to "C". See environ(5).
International Code Set Support
Single- and multi-byte character code sets are supported.
EXAMPLES
Move all files from directory
$1 to directory $2, and echo each move command just before doing it:
ls $1 | xargs -i -t mv $1/{} $2/{}
Combine the output of the parenthesized commands onto one line, then echo to the end of file log:
(logname; date; echo $0 $*) | xargs >>log
Ask the user which files in the current directory are to be archived then archive them into arch one at a
time:
ls | xargs -p -l ar r arch
or many at a time:
ls | xargs -p -l | xargs ar r arch
Section 1−−1070 Hewlett-Packard Company − 2 − HP-UX 11i Version 1: September 2005