I am trying to create an associative array in bash as follows
#!/bin/bash
hash["name"]='Ashwin'
echo ${hash["name"]}
This outputs the desired result: Ashwin on execution.
But when the key has a space in it,
#!/bin/bash
hash["first name"]='Ashwin'
echo ${hash["first name"]}
I get the following error
test2.sh: line 2: first name: syntax error in expression (error token is "name")
Are spaces allowed in it?
Bajji source
share