So the problem is: why does a_[a-z]*_data
match a_clean_0db_data
?
This can be broken down into four parts:
a_
matches the beginning of a_clean_0db_data
, leaving clean_0db_data
to be matched
[a-z]
matches any character in the range a-z
(e.g. c
), leaving lean_0db_data
to be matched
*
matches any number of characters, e.g. lean_0db
_data
matches the trailing _data
In regular expressions, [a-z]*
would mean any number of characters (including zero) in the range of a..z, but you are dealing with shell globbing, not with regular expressions.
If you want regular expressions, a few find
implementations have a -regex
predicate for that:
find . -maxdepth 1 -regex "^.*/a_[a-z]*_data$"
The -maxdepth
is only here to limit the search-results to the folder you are in.
The regular expression matches the entire filename, therefore I have added a ^.*/
to match the path-portion
a_*_data
matched` any of this files didn't surprise you?