This is my case scenario:luis@Balanceador:~$ echo ${array[@]}a bluis@Balanceador:~$ echo ${array[1]}aluis@Balanceador:~$ echo ${array[2]}bluis@Balanceador:~$ parallel echo ${array[]} ::: 1 2-bash: ${array[]}: bad substitutionluis@Balanceador:~$ parallel echo ${array[{}]} ::: 1 2-bash: {}: syntax error: operand expected (error token is {})luis@Balanceador:~$ parallel echo ${array[{1}]} ::: 1 2-bash: {1}: syntax error: operand expected (error token is {1})luis@Balanceador:~$ parallel echo ${array[{#}]} ::: 1 2-bash: {#}: syntax error: operand expected (error token is {#})How can I reference the individuals elements of some array on GNU Parallel?Sure this is an easy one, but I have not been able to find it on the manual.This question has been made to answer this other, but, after asking it, I considered they were two different questions.
GNU Parallel: How can I reference array elements?
bash;array;gnu parallel
While it looks easy, it is really very hard.Jobs started by GNU Parallel are not started inside the same shell as GNU Parallel is run from. So it looks like this:bash[1]---perl(running parallel)---bash[2]$array is defined in bash[1] but you want to use it in bash[2]. It is impossible to do completely (i.e. if you want write access to the array), but we can make a copy of $array available:env_parallel 'echo ${array[{}]}' ::: 1 2env_parallel (introduced in GNU Parallel 20140822) copies the entire environment of bash[1] to bash[2] (so your environment has to be kinda small) where it is initiated before the job is run.env_parallel is quite unstable, so if you find bugs, please report them.