数组长度

${#array[@]} 给出了数组 ${array[@]} 的长度:

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

这也适用于单个元素中的字符串:

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