bash test if dir is empty code example
Example: bash test empty directory
#!/bin/bash
DIR="/empty_dir"
# look for empty dir
if [ "$(ls -A $DIR)" ]; then
echo "Take action $DIR is not Empty"
else
echo "$DIR is Empty"
fi
#!/bin/bash
DIR="/empty_dir"
# look for empty dir
if [ "$(ls -A $DIR)" ]; then
echo "Take action $DIR is not Empty"
else
echo "$DIR is Empty"
fi