xargs is great.

But why?

You should care about xargs if you believe what I write about command line tools in general, because xargs turns all of those tools into n-dimensional swiss army knives.

Briefly: xargs takes a command that you want to run as its argument and reads the inputs (arguments) to that command from STDIN.

It’s remarkably powerful when combined with any other tool that writes in a predictable way to stdout.

Here are some invocations that I like:

  1. The -L 1 argument to xargs means “run this command once per line.” Without this, commands are executed once per separator (e.g. space or line) found in the input.↩︎

Share on: Hacker News Twitter