TECHIES WORLD

For Techs.... Techniques.... Technologies....

CpanelLinux

How to check bash array is empty or not

Suppose that the array need to check is $myarray.

Here we are going to verify the count of elements is zero.

if [ ${#myarray[@]} -eq 0 ]; then

echo "Arrary is empty"

else

echo "Array is not empty"

fi

 

Leave a Reply