Run a command in parallel

Hi all,

How do i run a command in parallel 50 times and capturing the result of each run in a separate file

Eg: myApp arg1 > run1.txt
myApp arg1 > run2.txt
:::::::::::::::::::::::::
:::::::::::::::::::::::::
myApp arg1 > run50.txt

The above way is sequential.

Any help is appreciated
Thanks,
Jak

#!/bin/sh
num=0
while [ $num -lt 50 ]
do
  num=`expr $num + 1`
  myApp arg1 > run${num}.txt &
done

Thanks for the help!

Jak

Use shell arithmetic instead of calling an external command for every iteration:

num=$(( $num + 1 ))