must use subscript when assigning associative array



  • Full Error:

    $ ./associative_array.sh
    ./associative_array.sh: line 3: MyBucketList: [1]"See The Grand Canyon": must use subscript when assigning associative array
    ./associative_array.sh: line 3: MyBucketList: [2]"Go to Mars": must use subscript when assigning associative array
    ./associative_array.sh: line 3: MyBucketList: [3]"Climb Mount Everest": must use subscript when assigning associative array
    

    Action(s):
    When running the bash script with an associative array

    MyBucketList=([1]"See The Grand Canyon" [2]"Go to Mars" [3]"Climb Mount Everest")
    

    The Fix:
    Associative Array incorrectly defined.

    The key/value pairs have to have an equals between them as follows:

    MyBucketList=([1]="See The Grand Canyon" [2]="Go to Mars" [3]="Climb Mount Everest")
    

Log in to reply
 

© Lightnetics 2024