不,bash 数组只是一维的。您应该能够构造数组键来伪造多维性。例如,如果您想要 JSON 对象
x = {'foo': {'a': 1, 'b': 2}, 'bar': {'c': 3, 'd', 4}}
Run Code Online (Sandbox Code Playgroud)
在 bash 中,你必须做类似的事情
declare -A x
x[foo,a]=1
x[foo,b]=2
x[bar,c]=3
x[bar,d]=4
Run Code Online (Sandbox Code Playgroud)
并参考,例如
i=foo
j=b
echo "${x[$i,$j]}"
Run Code Online (Sandbox Code Playgroud)