a=() a["/dev"]=3 echo ${a["/dev"]}
Run the above code will get error:
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:
declare -A a a["/dev"]=3 echo ${a["/dev"]}