Subject: Re: Bug #385069: dirempty/exists

From: Michael Cetrulo <[email-masked]>
Date: Fri, 16 Dec 2011 14:04:59 -0200

I think you can achieve this with a bash function:

    exists() (
        shopt -s nullglob dotglob; shopt -u failglob
        a=($1); [[ ${a##*/} != . && ${a##*/} != .. && -e $a ]] && return
    )

you'll use it with literal globs (like you do with "find -name" for
instance) eg:

    if exists 'mydir/*'; then
        echo "mydir is not empty"
    else
        echo "mydir is empty"
    fi

also notice the faq cited earlier has moved:
http://mywiki.wooledge.org/BashFAQ/004