I set an array named “disks” to the following words - sdb sdc sdd
in bash shell:
declare -A disks
Machine=worker01
disks[$Machine]="sdb sdc sdd"
now we print all words as the following:
echo ${disks[@]}
sdb sdc sdd
now we want to print the first item ( that should be sdb )
echo ${disks[0]}
but no output
the same with:
echo ${disks[1]}
echo ${disks[2]}
also with:
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 can I print the first words of the array “disks” - when Machine=worker01
echo ${disks[$Machine]}