[bash] is this directory empty ?

  • here a simply way to test if a directory is empty :

$ [ "$(ls -A /path/to/directory)" ] && echo "Not Empty" || echo "Empty"

  • and here, a way to find empty directories from a location :

find /path/to/parent/directory -type d -empty

tips found from this source : http://www.cyberciti.biz/faq/linux-unix-shell-check-if-directory-empty/