# Created on savesnippets.com · https://savesnippets.com/HSTkgmoZfHa0Vr # Resize 100 images, 8 in parallel ls *.jpg | xargs -P 8 -I{} convert {} -resize 1024 resized/{} # More robust: -print0 + -0 for filenames with spaces/newlines find . -name "*.log" -print0 | xargs -0 -P 4 -I{} gzip {} # Run a heavy fn over a list — wrap as a function and export it process() { local url="$1" curl -fs "$url" -o "downloads/$(basename "$url")" } export -f process cat urls.txt | xargs -P 10 -I{} bash -c 'process "$@"' _ {} # Limit total work but cap parallelism — GNU parallel is cleaner if installed seq 1 100 | xargs -P 16 -I{} ./worker.sh {}