Text Processing

xargs

Builds command arguments from input.

xargs converts standard input into arguments for another command, often bridging find or grep output to action commands.

Syntax
xargs [options] command

Arguments explained

  • command is what to run.
  • -0 reads null-separated input.
  • -n controls arguments per command.
  • -I replaces a placeholder.

Common examples

Remove files listed by find safely for spaces
find . -name '*.tmp' -print0 | xargs -0 rm

Uses null separators to handle unusual filenames.

Run one command per item
printf '%s\n' a b | xargs -n 1 echo item:

Demonstrates grouping one input item per command.

xargs Command
FieldDetails
Commandxargs
CategoryText Processing
Primary useBuilds command arguments from input.
Syntaxxargs [options] command