xargs command
Build and run commands from standard input.
- Shell & scheduling
- Package findutils
- 6 options · 5 examples
Syntax
xargs [options] [command]Provided by the findutils package. Run man xargs for the full manual.
Common options
| Option | What it does |
|---|---|
-n N | Pass at most N arguments per command |
-I {} | Replace {} with each input item |
-0 | Items are separated by NUL (use with find -print0) |
-P N | Run up to N commands in parallel |
-r | Don't run the command if the input is empty |
-p | Ask before each command |
Examples
Delete files found by find
find . -name "*.tmp" -print0 | xargs -0 rm -fOne argument per command
echo a b c | xargs -n 1 echoUse a placeholder
cat urls.txt | xargs -I {} curl -sO {}Run 4 jobs in parallel
ls *.png | xargs -P 4 -I {} optipng {}Grep inside the files find returns
find . -name "*.conf" | xargs grep -l "listen"
No example matches. Check the options table or search the guides.
xargs guides
- xargs Command in Linux with Useful Examples Linux Commands · Updated Apr 2025
- How to use ‘find’ command with ‘xargs’ to parallelize file operations in Linux Linux Commands · Updated Apr 2025
