I'm a actually working on a Bash Script that search the backups directories to delete.
I have a directory ~/test/ that contain some "backups" directories named as follow :
20200302_000001-daily
20200330_000001-monthly
20200528_000001-weekly
20200529_000001-daily
20200530_000001-daily
20200531_000001-monthly
20200601_000001-daily
20200602_000001-daily
With a find command, I'm trying to record all directory's name that contain the string daily or weekly in an array :
BACKUPS=(`find $BACKUP_DIR -maxdepth 1 -regex ".*[daily|weekly]$"`) // where $BACKUP_DIR is the absolute path to the "test" directory.
The problem is, that the regex match all the backups directories and after hours of research, I didn't find why.
It's interesting to know that if I use the regex .*daily$, the regex match all the "daily" backups directories (and .*weekly$ match all the "weekly" backups directories).
I know there are other ways to do it, but I really want to success with a regex.