Issue
I'm trying to run several python commands in parallel with the parallel command.
I tried playing around with the parallel command but it didn't perform as what I expected
Here's my shell script
arr_1=(a.log b.log c.log d.log)
arr_2=(a.json b.json c.json d.json)
parallel --halt 2 echo "{1} {2}" ::: "${arr_1[@]}" ::: ${arr_2{@}}
What I expected is:
a.log a.json
b.log b.json
c.log c.json
d.log d.json
But what I got was:
a.log a.json
b.log b.json
c.log c.json
d.log d.json
a.log a.json
b.log b.json
c.log c.json
d.log d.json
a.log a.json
b.log b.json
c.log c.json
d.log d.json
a.log a.json
b.log b.json
c.log c.json
d.log d.json
It looks like the shell script ran the command 16 times.
My guess is I didn't pass the two lists correctly, but I'm not sure about it.
Solution
You are looking for :::+
:
parallel --halt 2 echo "{1} {2}" ::: "${arr_1[@]}" :::+ ${arr_2[@]}
Available since 20160422.
Answered By - Ole Tange