How are the "Associative Arrays" and "Indexed Arrays" declared in bash?
Issue
- In this version of bash, the
associative arrays
are not working :
[root@rhel7u3-1 ~]# rpm -qa | grep bash
bash-4.2.46-20.el7_2.x86_64
bash-completion-2.1-6.el7.noarch
[root@rhel7u3-1 ~]# declare -a B
[root@rhel7u3-1 ~]# B[ddd]=aa
[root@rhel7u3-1 ~]# B[AB]=cc
[root@rhel7u3-1 ~]# echo ${B["AB"]}
cc
[root@rhel7u3-1 ~]# echo ${B["ddd"]}
cc
- This is not correct for
Bash Associative Arrays
on my system withRed Hat Enterprise Linux 7.3
[root@test ~]# rpm -q bash
bash-4.2.46-21.el7_3.x86_64
[root@test ~]# declare -a test
[root@test ~]# test[a]=what
[root@test ~]# echo ${test[a]}
what
[root@test ~]# test[b]=that
[root@test ~]# echo ${test[a]}
that
[root@test ~]# echo ${test[b]}
that
Environment
Red Hat Enterprise Linux 7
bash-4.2.46-20.el7_2.x86_64
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.