JavaScript
x
a=()
a["/dev"]=3
echo ${a["/dev"]}
Run the above code will get error:
JavaScript
syntax error: operand expected (error token is "/dev")
If I modify key=’dev’, it works. So, the key only can be a simple string?
Advertisement
Answer
You must declare the array associative first:
JavaScript
declare -A a
a["/dev"]=3
echo ${a["/dev"]}