I need to check if a directory already exists, in this case the one with a number suffix, and I won't know the exact number. Example directories to search:
[[ -d /usr/names ]] && echo "yes" || echo "no"
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
If you want to do it all in bash and the file's backup date is always the same number of digits (i.e., yyyymmddhhmmssxx), then a bash file expansion expression like:
[0-9] for each digit) would match, but if the number sequence were a different number of digits, you would need an expression for each length.
A good description of file expansion options can be found in the GNU Bash Manual Filename Expansion section.