Name

xargs

Synopsis

    xargs [options] [command]

Execute command (with any initial arguments), but read remaining arguments from standard input instead of specifying them directly. xargs passes these arguments in several bundles to command, allowing command to process more arguments than it could normally handle at once. The arguments are typically a long list of filenames (generated by ls or find, for example) that get passed to xargs via a pipe.

Without a command, xargs behaves similarly to echo, simply bundling the input lines into output lines and printing them to standard output.

Common Options

-E string

Stop passing arguments when argument string is encountered.

-I string

Pass arguments to command, replacing instances of string on the command line with the current line of input.

-L n

Execute command for n lines of arguments.

-ncount, --max-args=count

Execute command with up to count arguments.

-p, --interactive

Prompt for a y to confirm each execution of command. Implies -t.

-smax, --max-chars=max

Each argument list can contain up to max characters. (Older systems limited n to 470. The default is system-dependent.)

-t, --verbose

Echo each command before executing.

-x, --exit

Exit if argument list exceeds n characters (from -s); -x takes effect automatically with -i and -l.

Solaris and GNU/Linux Options

-e[string], --eof[=string]

Use string as the default logical EOF string (default is underscore). An omitted string disables the logical EOF capability.

-i[string], --replace[=string]

Like -I but ...

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.