Array Length
suggest change${#array[@]} gives the length of the array ${array[@]}:
array=('first element' 'second element' 'third element')
echo "${#array[@]}" # gives out a length of 3
This also works with strings in single elements:
echo "${#array[0]}" # gives out the length of the string at element 0: 13
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents