## 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
echo "${#my_array[@]}"
echo "${#your_array[@]}"
# Basic syntax:
YOUR_VAR=( $YOUR_VAR ) # convert the string to an array
echo ${#YOUR_VAR[*]} # use the standard bash syntax to get the length of arrays
# Example usage:
YOUR_VAR='some string with words'
YOUR_VAR=( $YOUR_VAR )
echo ${#YOUR_VAR[*]}
--> 4
# Note, to convert the array back to a string, use:
YOUR_VAR="${YOUR_VAR[*]}"