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"


echo "Array is not empty"



Leave a Reply

Your email address will not be published. Required fields are marked *