This seems to work http://www.cyberciti.biz/faq/linux-unix-shell-check-if-directory-empty/