Question: GNU parallel command with several multiple arguments
1
gravatar for FGV
5 weeks ago by
FGV120
FGV120 wrote:

Dear all,

I am trying to use gnu parallel to run a command, where each command uses one from the first argument and two from the second. I've tried several things but without success.

I'd like to have something like:

parallel "command -t {1} {2} {3} > {1}_{2/..}.out " ::: 4 8 ::: File1 File2 File3 File4

and output:

command -t 4 File1 File2 > 4_File1.out
command -t 8 File1 File2 > 8_File1.out
command -t 4 File3 File4 > 4_File3.out
command -t 8 File3 File4 > 8_File3.out

Is it possible?

thanks,

gnu parallel parallel • 162 views
ADD COMMENTlink modified 5 weeks ago by ole.tange3.9k • written 5 weeks ago by FGV120
3
gravatar for ole.tange
5 weeks ago by
ole.tange3.9k
Denmark
ole.tange3.9k wrote:
parallel --plus "command -t {1} {2} {3} > {1}_{2/..}.out " ::: 4 8 ::: File1 File3 :::+ File2 File4
ADD COMMENTlink written 5 weeks ago by ole.tange3.9k
2
gravatar for microfuge
5 weeks ago by
microfuge1.8k
microfuge1.8k wrote:

I think arguments can be grouped by -N argument.

parallel --dry-run -N 2 command -t {1} {2} {4} {1}_{2}.out ::: 4 8 ::: File1 File2 File3 File4

ADD COMMENTlink written 5 weeks ago by microfuge1.8k

thanks, that worked!

But can you explain a bit more the logic behind it? I tried using -N 2 but with {1} {2} {3}, and that did not work. Why does it work with {4}?

thanks

ADD REPLYlink written 5 weeks ago by FGV120
2

Sure. As per how I understand it, it is easiest to first print what gnuparallel sees and then cherrypick the argument numbers.

parallel --dry-run -N 2 command -t {} ::: 4 8 ::: File1 File2 File3 File4

will return

command -t 4 File1 4 File2
command -t 4 File3 4 File4
command -t 8 File1 8 File2
command -t 8 File3 8 File4

From these, the third one needs to be removed to generate the required command format so {1} {2} {4} and the output should be redirected to to a file which is {1}_{2}.out

ADD REPLYlink modified 5 weeks ago • written 5 weeks ago by microfuge1.8k

nice trick. :) Thanks,

ADD REPLYlink written 5 weeks ago by FGV120
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1019 users visited in the last hour