I am using GNU Parallel to create a file of python jobs. I was looking to have the file look like such:
job_num, args
001, -a 1 -b 2
002, -a 1 -b 4
003, -a 2 -b 2
004, -a 2 -b 4
The idea being that each group of args can be configured at file generation while having leading zero job numbers.
Here is one thing I tried:
parallel --rpl '{0#} $_=sprintf("%02d",$job->seq())' echo {0#}, -a {1} -b {2} ::: 1 2 ::: 2 4
This results in:
01 01, -a 1 -b 2
02 02, -a 1 -b 4
03 03, -a 2 -b 2
04 04, -a 2 -b 4
The result that I did not expect was the double set of job numbers (with 3 expansions, it results in 3 job numbers). Any thoughts on how to make what I am trying work?
Tested on versions 20170322 & 20210222.
Related posts (tried the contents of each):
Something like this:
parallel --rpl '{0#} 1 $f=1+int((log(total_jobs())/log(10))); $_=sprintf("%0${f}d",seq())' echo '{0#}, -a {1} -b {2}' ::: {1..9} ::: {1..12}
1+int((log(total_jobs())/log(10)))
computes the width of total_jobs()
in digits.