Skip to main content
missing quotes
Source Link
Stéphane Chazelas
  • 585k
  • 96
  • 1.1k
  • 1.7k

Welcome to eval hell! Once you start using it, you never get rid of it.

for journal in A B all
do
  eval "echo \$\"\${${journal}_1999[@]}"\""
done

There might be a much better way to do it, but I never bother with associative or otherwise nested arrays in shell scripts. If you need such data structures, you might be better off with a scripting language that supports them natively.

Actually, bash has support for associative arrays after a fashion. Whether they can be useful to you is another question, it's not portable to other shells in any case.

Welcome to eval hell! Once you start using it, you never get rid of it.

for journal in A B all
do
  eval "echo \${${journal}_1999[@]}"
done

There might be a much better way to do it, but I never bother with associative or otherwise nested arrays in shell scripts. If you need such data structures, you might be better off with a scripting language that supports them natively.

Actually, bash has support for associative arrays after a fashion. Whether they can be useful to you is another question, it's not portable to other shells in any case.

Welcome to eval hell! Once you start using it, you never get rid of it.

for journal in A B all
do
  eval "echo \"\${${journal}_1999[@]}\""
done

There might be a much better way to do it, but I never bother with associative or otherwise nested arrays in shell scripts. If you need such data structures, you might be better off with a scripting language that supports them natively.

Actually, bash has support for associative arrays after a fashion. Whether they can be useful to you is another question, it's not portable to other shells in any case.

Source Link
frostschutz
  • 52.1k
  • 7
  • 129
  • 179

Welcome to eval hell! Once you start using it, you never get rid of it.

for journal in A B all
do
  eval "echo \${${journal}_1999[@]}"
done

There might be a much better way to do it, but I never bother with associative or otherwise nested arrays in shell scripts. If you need such data structures, you might be better off with a scripting language that supports them natively.

Actually, bash has support for associative arrays after a fashion. Whether they can be useful to you is another question, it's not portable to other shells in any case.