陣列長度

${#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