How to Use xargs to Build Commands From Input in Linux

xargs takes input from standard input (often piped from another command) and uses it to build and execute a new command.

Published October 2, 2026

xargs takes input from standard input (often piped from another command) and uses it to build and execute a new command.

Key points

  • Many commands like find print a list of results but can't directly run another command on each one — xargs bridges that gap
  • find . -name "*.tmp" | xargs rm deletes every file that find located
  • xargs -I {} lets you place each input item at a specific position in the command, e.g. xargs -I {} mv {} /archive/

Example

find . -name "*.tmp" | xargs rm
More Linux articles