Languages
[Edit]
EN

Bash - check array size

3 points
Created by:
Teilsa
345

This article will show you how to check the array size in Bash.

Quick solution:

#!/bin/bash

array=(Tom Kate Mary)
length=${#array[@]}

echo $length

Example output:

3

 

Alternative solution

It is possible to use an alternative approach to get array size - it is ${#array[*]}.

#!/bin/bash

array=(Tom Kate Mary)
length=${#array[*]}

echo $length

Example output:

3

Bash

Bash - check array size
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join