Bash 5 reference · Text and System Tools
xargs (Linux command)
Build and run commands from input lines, in batches or in parallel; pair with find -print0 and xargs -0 for safe file names.
Bash 5
Syntax
xargs [-0] [-n N] [-P N] [-I {}] COMMAND
Parameters
| Parameter | Description |
|---|---|
-0 |
Input is NUL-separated. |
-n N |
At most N arguments per command. |
-P N |
Run N commands in parallel. |
-I {} |
Replace {} with each input line. |
Examples
printf '%s\n' a b c d | xargs -n 2 echo batch:
Output
batch: a b batch: c d
Run this on your computer — see “Get Started” for setup.
touch 'my file.txt' other.txt
find . -name '*.txt' -print0 | sort -z | xargs -0 -I {} echo "found: {}"
Output
found: ./my file.txt found: ./other.txt
Run this on your computer — see “Get Started” for setup.
Related
find· Find files and directories by name, type, size, age or permissions, and act on them with -exec, -delete or xargs.- Bash find and xargs · tutorial