Chris Jefferson Chris Jefferson - 2 years ago 102
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download