commands

xargs — build argument lists

Builds batches of arguments from input. Default whitespace and quoting rules are unsuitable for arbitrary paths. -0 reads NUL-delimited input; GNU -r skips empty input. Status can reflect child failures; 123 indicates a child exited 1–125. Example assumes a fresh search-transform lab fixture.

Formal Syntax & Structure

linux syntaxlinux
xargs [OPTION]... [COMMAND [INITIAL-ARGS]]

Parameters & Attributes

NameTypeDescription
-0optionRead NUL-separated arguments; disable quote and backslash parsing.
-roptionGNU extension: do not invoke command if no input arguments.
COMMANDoperandExecutable to invoke; GNU xargs defaults to echo if omitted.
INITIAL-ARGSoperandFixed arguments placed before each batch of input arguments.

Return Value

exit status and output

Builds batches of arguments from input. Default whitespace and quoting rules are unsuitable for arbitrary paths. -0 reads NUL-delimited input; GNU -r skips empty input. Status can reflect child failures; 123 indicates a child exited 1–125.

Working Example

Example Snippetlinux
printf 'a b\0c\0' | xargs -0 -r printf '[%s]\n'
Linux Reference