Search code examples
arraysbashgnu-parallel

Feed GNU parallel with an array?


How to feed a command in GNU parallel with an array? For example, I have this array:

x=(0.1 0.2 0.5)

and now I want to feed it to some command in parallel

parallel echo ::: $x

This does not work. It is feeding all the arguments to a single call, since it prints

0.1 0.2 0.5

instead of

0.1
0.2
0.5

which is the output of

parallel echo ::: 0.1 0.2 0.5

How can I do it right?


Solution

  • If you want to provide all the elements in the array use:

    parallel echo ::: ${x[@]}