-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
  • 15,211
  • 3
  • 34
  • 44
hd.
  • 17,596
  • 46
  • 115
  • 165
  • 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
  • 24,082
  • 14
  • 97
  • 108