weI set inan array disksnamed “disks” to the following words - sdb sdc sdd
from linuxin bash shell:
bash declare -A disks Machines=worker01Machine=worker01 disks[$Machines]="sdbdisks[$Machine]="sdb sdc sdd" now we print all words as the following:
echo ${disks[@]} sdb sdc sdd now we want to print the first arrayitem ( that should be sdb )
echo ${disks[0]} but no output
the same aboutwith:
echo ${disks[1]} echo ${disks[2]} also aboutwith:
echo ${disks[3]} echo ${disks[4]} . . . …
what is wrong here?
also not as:
for i in {1..100} > do > echo ${disks[$i]} > done so how tocan I print the first words fromof the array disks“disks” - when Machines=worker01Machine=worker01
echo ${disks[$Machines]disks[$Machine]}