< BACK

Bash tips, tricks and code snippets

Test if a directory is empty

As explained here


if [ -z "$(ls -A /path/to/dir)" ]; then
   echo "Empty"
else
   echo "Not Empty"
fi