All tags
xargs
Narrow down
Other tips10
- Tip
printf '%s\n' a b c d e f | xargs -n1 -P3 --process-slot-var=SLOT sh -c 'echo "slot $SLOT got $0"; sleep 0.2'Xargs --process-slot-var gives every parallel job a worker numberSets an environment variable in each parallel xargs job, holding the slot number it runs in.3 Dec 2026 - Tip
find . -name '*.orig' -print0 | xargs -0 -p rmXargs -p asks for a yes before each command it runsShows every command xargs is about to run and waits for you to confirm it.30 Nov 2026 - Tip
find . -name '*.gz' -print0 | xargs -0 -n 1 gzip -tXargs exits with 123 when one of its commands failedExplains xargs exit codes, so a script can tell whether every command it ran succeeded.30 Nov 2026 - Tip
printf 'a b\nc d\n' | xargs -L 1 echo line:Xargs -L 1 runs one command per input line, not per wordKeeps each input line together as the arguments of one command run.30 Nov 2026 - Tip
printf 'x\ny\n' | xargs -t touchXargs -t prints each command before it runsShows the exact commands xargs builds, which makes a pipeline easy to check and debug.30 Nov 2026 - Tip
xargs --show-limits < /dev/nullxargs can show how long one command line may be on your systemPrints the system's limit on command length and the buffer size xargs really uses.30 Nov 2026 - Tip
printf 'old1.txt new1.txt\nold2.txt new2.txt\n' | xargs -n 2 mvXargs -n 2 hands the input to a command two items at a timeSplits a list into fixed-size groups, so each command run gets exactly the number of arguments it needs.30 Nov 2026 - Tip
find . -maxdepth 1 -name '*.conf' | xargs -I {} cp {} {}.bakXargs -I {} puts each input line exactly where you want it in the commandPlaces each input line at a chosen spot in the command, not just at the end.27 Nov 2026 - Tip
find . -name '*.png' -print0 | xargs -0 -n 1 -P 4 optipngXargs -P runs commands in parallel, no GNU parallel neededRuns a command on several inputs at the same time instead of one after another.27 Aug 2026 - Tip
find . -name '*.tmp' -print0 | xargs -0 rm --find -print0 | xargs -0 survives file names with spacesPasses file names between find and xargs safely, even with spaces or quotes in them.8 Aug 2026
Shell2
- Tip
grep -l 'TODO' *.py | xargs -o vimXargs -o lets an interactive program like vim work from a pipeConnects the command xargs starts to your terminal, so editors and prompts work normally.30 Nov 2026 - Tip
xargs -a hosts.txt -n 1 ssh-keygen -Rxargs -a reads the list from a file and keeps standard input freeTakes the items from a file so the command that xargs runs can still use the keyboard.30 Nov 2026
Docker1
Nothing matches.