parallel
[Top][All Lists]
Advanced

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

RE: bash arrays in parallel


From: Cook, Malcolm
Subject: RE: bash arrays in parallel
Date: Mon, 9 Jan 2012 09:11:48 -0600

 

parallel my_program ::: address@hidden

 

 

~Malcolm

 

From: address@hidden [mailto:address@hidden On Behalf Of giorgos sermaidis
Sent: Sunday, January 08, 2012 7:30 PM
To: address@hidden
Subject: bash arrays in parallel

 

Hello all,

 

I am trying to run a program with different arguments which are read from a bash array. So far I had been doing

 

x=(0.1 0.2 0.3) # the arguments

 

for i in $(seq 0 1 2)

do

my_program ${x[$i]} &

done

 

This would run my_program for all arguments in parallel.

 

I have been trying to achieve the same result using GNU parallel but have not been able to so far. I have been trying (I have replace my_program by echo for simplicity)

 

(1) seq 0 1 2 | parallel echo ${x[{1}]}

(2) seq 0 1 2 | parallel echo $"{"x[{1}]"}"

(3) seq 0 1 2 | parallel echo \${x[{1}]}

 

with outputs

 

(1) bash: {1}: syntax error: operand expected (error token is "{1}")

(2) no output

(3) {x[0]}
     {x[1]}
     {x[2]}

Is there any way to get what is expected, i.e.

0.1

0.2

0.3

?

 

I have read the parallel manual about quoting but have not worked it out completely... Thanks in advance for any suggestions!

 

 

 

 

 

 

 


reply via email to

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