Bash tips, tricks and code snippets
Testing whether a glob has any matches
The following will test if a
glob pattern matches and exits with a status of 0 for one or more results and 0 for none:
compgen -G __GLOB__
if compgen -G "/tmp/*" > /dev/null; then echo "Some files exist in tmp dir." fi
This is well explained in this posting.