Checking whether a directory is empty can be acheived using an if-else construct.
It has the following syntax:
if [[ condition ]] # there must be a space between the condition and the square brackets
then
<execute command>
else # this is optional
<execute another command>
fi # this closes the statement
Condition for checking if empty:
-z "$(ls -A /path/to/dir/)"
So in summary this can be achieved as follows:
temp_dir = "some-path"
if [ -z "$(ls -A $temp_dir)" ]; then
echo "$temp_dir empty"
else
echo "Not Empty"
fi