EN
Bash - check array size
3
points
This article will show you how to check the array size in Bash.
Quick solution:
length=${#array[@]}
or:
length=${#array[*]}
Practical examples
@ based solution
It is possible to use ${#array[@]} to get array size .
#!/bin/bash
array=(Tom Kate Mary)
length=${#array[@]}
echo $length
Example output:
3
* based solution
It is possible to use ${#array[*]} to get array size .
#!/bin/bash
array=(Tom Kate Mary)
length=${#array[*]}
echo $length
Example output:
3