Bash Array Length


Example

${#array[@]} gives the length of the array ${array[@]}:

array=('first element' 'second element' 'third element')
echo "${#array[@]}" # gives out a length of 3

This works also with Strings in single elements:

echo "${#array[0]}"    # gives out the lenght of the string at element 0: 13