{mosimage}
Here is a method of testing whether a directory is empty or not….
Let say we want to know if /tmp is empty or not.
cd /tmp
test -z "find . ! -name . -prune | sed q" && echo empty
rc=$?
if [[ $rc = 0 ]];then
echo "the current directory is empty."
else
echo "the current directory is not empty."
fi