GNU parallel - two parameters from array as parameter
Omitting your other parallel
flags just to stay focused...
parallel --link pf ::: A B ::: C D
This will run your function first with a=A
, b=C
followed by a=B
, b=D
or
a=A b=C
a=B b=D
Without --link
you get full combination like this:
a=A b=C
a=A b=D
a=B b=C
a=B b=D
Update: As Ole Tange metioned in a comment [since deleted - Ed.] there is another way to do this: use the :::+
operator. However, there is an important difference between the two alternatives if the number of arguments is not the same in each param position. An example will illustrate.
parallel --link pf ::: A B ::: C D E
output:
a=A b=C
a=B b=D
a=A b=E
parallel pf ::: A B :::+ C D E
output:
a=A b=C
a=B b=D
So --link
will "wrap" such that all arguments are consumed while :::+
will ignore the extra argument. (In the general case I prefer --link
since the alternative is in some sense silently ignoring input. YMMV.)