xargs

Build and execute commands from standard input.

medium risk

interactive breakdown — edit the command and press Explain
$ 
⚠ Risks & cautions
What it does

xargs reads items from stdin and passes them as arguments to a command. Handles the case where a command doesn't natively read from stdin. With -P, it runs multiple processes in parallel — a simple way to parallelize shell operations.

Common flags
FlagMeaning
-n --max-argsMax arguments per command invocation
-I --replaceReplace placeholder string with each input item
-P --max-procsRun N processes in parallel
-p --interactivePrompt before each execution
-0 --nullInput items are null-terminated (safe for filenames with spaces)
Examples
find . -name '*.log' | xargs wc -lCount lines in all log files · explain & risk-check →
cat pods.txt | xargs -I{} kubectl delete pod {}Delete pods listed in a file · explain & risk-check →
find . -name '*.go' | xargs -P 4 gofmt -wFormat Go files in parallel · explain & risk-check →
find . -name '*.tmp' -print0 | xargs -0 rm -fSafe deletion with null-separated filenames · explain & risk-check →
Pro tip

Always use `find -print0 | xargs -0` when filenames might contain spaces or newlines — the default newline separator will cause silent failures.

Related
find parallel grep
Open the full explainer →More in Text Processing

Reference text is hand-written and may be incomplete — check man xargs for your version. Test destructive commands on a non-production system first.