Text and processing
The xargs command
Turns one command's output into arguments for another. Used when a command does not accept piped input.
Syntax
comando | xargs otro-comandoMost useful options
-n NPasses N arguments at a time-I {}Replaces {} with each itemCopy-ready examples
$ printf 'a b c\n' | xargs echoPass words to echoYou can try them in the browser terminal: it does not touch your computer.
Typical mistakes
- If file names contain spaces, xargs can break them: use -0 with find -print0.
FAQ
When do I need xargs?
When the second command expects arguments and does not read from a pipe, such as rm.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course