echo ${#arr[@]}

Category: Bash Scripting

echo ${#arr[@]}

Get the number of elements in an array

Prints the number of elements in the array. The # prefix means 'length of'.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.