XARGS(1V)

NAME
xargs - manipulate argument lists

SYNOPSIS
/usr/5bin/xargs [ -lnumber ] [ -ireplstr ] [ -nnumber ] [ -t ] [ -p ] [ -x ] [ -ssize ] [ -eeofstr ] [ command [ initial-arguments ]]

DESCRIPTION
Xargs performs one or more invocations of command (default echo(1)) with arguments composed from the set of initial-arguments and further arguments read from standard input. The initial arguments are prepended to the read arguments for each call of command (except when running under the -i option).

Arguments read from standard input are contiguous strings of characters separated by whitespace. Empty lines are discarded. Arguments may contain whitespace if suitably quoted with single or double quotes, or backslashes, in much the same manner as in the shell.

The manner in which argument composition takes place is controlled by the -i, -l, and -n options. If none of these are specified, then each invocation of command is passed the initial-arguments followed by as many arguments as could be read from standard input before an internal buffer fills up. This is repeated until end-of-file is reached on standard input.

OPTIONS
When conflicting options are specified, the last one has precedence.

-lnumber
    Command is executed for each number lines of standard input. The final invocation may have less than number arguments if there are not that many left. Empty lines are ignored. A line of the input file may be continued by making its last character a blank or tab. If number is omitted, 1 is assumed. This option switches on -x automatically.

-ireplstr
    Command is executed once for each line in standard input. The line is treated as a single argument, and is inserted into initial-arguments wherever the magic string replstr occurs in them. (If replstr is omitted, it defaults to `{}'). Whitespace at the start of the line is discarded. Up to five of the initial-arguments can contain one or more occurences of replstr, but the constructed argument must not exceed 255 characters. This options switches on -x automatically.

-nnumber
    Command is executed using as many arguments from standard input as possible, up to a maximum of number arguments. Fewer will be used if their total size exceeds the limit set by the -s option, and there may be fewer in the last invocation of command if there are less than number arguments remaining. If the -x option is also selected, then each set of number arguments must fit in the limit set by -s or else xargs will terminate.

-t  Trace execution. Each command and its arguments are echoed to standard output just before execution.

-p  Prompt mode. Trace mode is automatically turned on, and the user is prompted with the string `?...' before each command is executed. Any reply starting with `y' will execute the command; anything else skips that particular invocation.

-x  Terminate if any argument list would be greater than the limit set by -s. If none of -i, -l, and -n are specified, then the total length of all arguments must be within this limit.

-ssize
    Specifies the maximum size of each argument list. size may not exceed 470, which is also the default value if this option is left unspecified.

-eeofstr
    Set the logical end-of-file marker to eofstr. Xargs stops processing when either end-of-file is encountered or this string is read. The default value for this is underscore (`_'); to disable the logical end-of-file capability, specify the -e option without an eofstr.

Xargs terminates if it cannot execute command, or if it receives a return value of -1 from command.

EXAMPLES
This example moves all files from directory foo to directory bar after prompting the user about each one.

    ls foo | xargs -p -i mv foo/{} bar/{}

This example runs diff on successive pairs of files named in the file pairs.

    cat pairs | xargs -n2 diff

SEE ALSO
sh(1)