Chris Jefferson Chris Jefferson - 10 months ago 56
Bash Question

Executing a file with one command per line with xargs

I have a file which consists of a series of commands, one per line. For example:

./ fileA
./ fileB
./ fileC

I want to run these in parallel, using xargs.


Give this a try:

printf "%s\0" "$(cat afile)" | xargs -0 -P 3 -I xxx bash -c xxx

xargs is going to run 3 commands from afile in parallel.