-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.

1
  • This question has been asked before. See google. You'll find that bash does not support 2-D arrays natively but that there are work-arounds if you really need them. Commented Jul 4, 2016 at 6:06

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.