-1

I need to define an array like this:

declare -A myary
myary[fruits]=(apple peach benana)
myary[objects]=(car window door)

and loop through it.

How can I do it in shell scripting?

Thank you.

SLePort
  • 14,775
  • 3
  • 30
  • 41
hd.
  • 16,676
  • 43
  • 110
  • 160
  • This question has been asked before. See [google](https://www.google.com/#q=bash+two-dimensional+array). You'll find that bash does not support 2-D arrays natively but that there are work-arounds if you really need them. – John1024 Jul 04 '16 at 06:06

1 Answers1

0

You cannot. Bash does not support multidimensional arrays. However, you can use one-dimensional associative arrays, and there are workarounds found here.

Will
  • 22,773
  • 13
  • 90
  • 102