Shell/Bash: get length of array bash Example

By

Shell/Bash Example: This is the "get length of array bash" Example. compiled from many sources on the internet by SimpleTutorials.org

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

bash size of array

echo "${#my_array[@]}"


* Summary: This "get length of array bash" Shell/Bash Example is compiled from the internet. If you have any questions, please leave a comment. Thank you!

Others