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

Reply via email to