parallel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash arrays in parallel


From: Ole Tange
Subject: Re: bash arrays in parallel
Date: Thu, 12 Jan 2012 16:57:43 +0100

Read then man page for --xapply and then answer your own question.

/Ole

On Thu, Jan 12, 2012 at 4:41 PM, gsermaid <linuxfever@yahoo.gr> wrote:
> Ok, now suppose that my_program takes two arguments and I want to use
> parallel to run the program in pairs. For example, if
>
> x=(0.1 0.2 0.3)
> y=(0.4 0.5 0.6)
>
> then I want to get:
>
> my_program ${x[0]} ${y[0]}
> my_program ${x[1]} ${y[1]}
> my_program ${x[2]} ${y[2]}
>
> Now if I use  "parallel my_program ::: ${x[@]} ::: ${y[@]}"
> it will run a nested loop, ie arguments will be (0.1, 0.4), (0.1, 0.5),
> (0.1, 0.6) etc, which is not what I want.
>
> I know I can achieve running in pairs by using a table and --colsep but I
> was wondering whether I could avoid the use of tables.
> I also know that I could use something like
>
> z=(0.1 0.4 0.2 0.5 0.3 0.6)
>
> and run "parallel -N2 my_program {1} {2} :::: ${z[@]}",
>
> but this is not ideal since I need to create everytime the additional vector
> z (unless I am unaware of a bash function that combines vectors in that
> way.)
>
> Ideally, I would like to use something like in my original post
>
> parallel my_program ${x[{1}]} ${y[{1}]} :::: <(seq 0 2)
>
> which of course does not work.
>
> Thanks for any suggestions!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]