I am trying to parallel this for loop. I wasn't able to figure out how other people's answers substitute in the $a
value and because my program depends on it.
Here is the original code I want to parallelize. cvp is an executable Cpp program. The purpose of this script is to loop from 0 to 29 using file_0 to file_29 with pc_0 to pc_29 and 0 to 29 as arguments and generate output file named from output_0 to output_29. Note that the program is also memory intensive, so if I can just parallel 4 (which is the amount of core i have ) that would be great.
#!/bin/bash
#testing script
for a in {0..29}
do
set -x
./cvp -v -w 256 -F 16,0,0,0,0 -f 5 file_$a.gz >>output_$a pc_$a $a
done
Something like this:
parallel --results output_{} ./cvp -v -w 256 -F 16,0,0,0,0 -f 5 file_{}.gz pc_{} {} ::: {0..29}
or:
parallel ./cvp -v -w 256 -F 16,0,0,0,0 -f 5 file_{}.gz pc_{} {} ">>" output_{} ::: {0..29}