Test whether a glob has any matches in bash
- by Ken Bloom
If I want to check for the existance of a single file, I can test for it using test -e filename or [ -e filename ].
Supposing I have a glob and I want to know whether any files exist whose names match the glob. The glob can match 0 files (in which case I need to do nothing), or it can match 1 or more files (in which case I need to do something). How can I test whether a glob has any matches.?
(test -f glob* fails if the glob matches more than one file.)