Bootstrap FreeKB - Bash (Scripting) - Count values in a list
Bash (Scripting) - Count values in a list

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter 6f79da in the box below so that we can be sure you are a human.