xargs

The command that reads items from its standard input and runs another command with them as arguments, in batches.

Without -0, file names containing spaces or quotes are split or mangled, and commands act on the wrong files.

In more detail

It bridges tools that print file names and tools that only accept arguments, as in find ... | xargs grep. By default it splits on any whitespace and treats quotes specially, so names with spaces break apart; use find -print0 with xargs -0. -n limits how many arguments go to each run.

Example

find data -name "*.log" -print0 | xargs -0 grep -c start

Related terms

Taught in

References