[Top][All Lists]

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

bash arrays in parallel

From: giorgos sermaidis
Subject: bash arrays in parallel
Date: Mon, 9 Jan 2012 01:30:23 +0000 (GMT)

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)
my_program ${x[$i]} &

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]}

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

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]