Bash Arrays Array Length

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

${#array[@]} gives the length of the array ${array[@]}:

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

This works also with Strings in single elements:

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


Got any Bash Question?