Need to execute 2 scripts, wait, execute 2 more wait, till end of file

:cool:

I need to execute a shell script to do the following:

cat a file
run two back ground processes using the first two values from the file
wait till those background processes finish
run two more background processes using the next two values from the file
wait till those background processes finish
etc till the end of the file.

Can anyone give me a way to do this? I cannot run all of the background processes at the same time, I can only do two at time.

You said it yourself...

runtask arg &
runtask arg &
wait
...