How do I define an associative array in a bash shell script?
-
Define the arrary.
declare -A MyBucketList MyBucketList=([1]="See The Grand Canyon" [2]="Go to Mars" [3]="Climb Mount Everest") echo ${MyBucketList[3]}
Reference an element of the above array.
Usage is ${name[word]}
echo ${MyBucketList[3]}
Running the script with
echo ${MyBucketList[3]}
give the result:$ ./associative_array.sh Climb Mount Everest
© Lightnetics 2024