array length bash code example
Example 1: get length of array bash
## define it
distro=("redhat" "debian" "gentoo")
## get length of $distro array
len=${#distro[@]}
## Use bash for loop
for (( i=0; i<$len; i++ )); do echo "${distro[$i]}" ; done
Example 2: bash size of array
echo "${#my_array[@]}"
Example 3: bash map lenght
$ declare -A array
$ array[foo]='something'
$ array[bar]='blah'
$ array[42]='nothing'
$ echo ${#array[@]}
3