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-comando

Most useful options

-n NPasses N arguments at a time
-I {}Replaces {} with each item

Copy-ready examples

$ printf 'a b c\n' | xargs echoPass words to echo

You 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.

Related commands

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