A command that constructs an argument list for a command from text given as xargs' standard input (or read from a specified file) thus allowing execution on the results of a search, for example. It is provided by the findutils package
xargs is a command for constructing and executing commands from standard input. xargs reads delimited strings and executes command-line utilities with the strings as arguments.
It is common to pass strings to xargs via standard output using a pipe (|).
However, xargs can be told to read from another file instead of standard input by passing the --arg-file or -a option, as demonstrated, for example in this answer. This makes is a surprisingly versatile utility.
xargs is provided by the findutils package which is part of the default Ubuntu installation in all current versions. This package also provides find. The two commands may be used together, for example:
find path tests | xargs commands
Since xargs will normally split on spaces, it's advisable to pass null-delimited lists to it, and use the -0 flag:
find ... -print0 | xargs -0 ...
find can execute commands on the found files (either with builtin actions or using -exec) so xargs may rarely be needed with it, but locate cannot execute commands on its results, so xargs may be useful with locate, again using null delimiting if filenames may contain spaces:
locate -0 pattern | xargs -0 command
The ability to pass alternative files to STDIN to xargs allow it to be used beyond the classic usages mentioned above. For example, instead of constructs like:
command $(cat file)
We can use something like:
xargs -a file command