Bash (Scripting) - Count values in a list
by
Jeremy Canfield |
Updated: March 14 2023
| Bash (Scripting) articles
Let's say you have an list of fruit.
fruit=(banana apple orange grapes)
Here is how you would return the number of elements in the list.
count=${#list[@]}
echo $count
Which should return the following.
4
Did you find this article helpful?
If so, consider buying me a coffee over at