Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bunch js and css files in a directory. Some of them have been given a name based on an md5() of their content (looks like f10521a21bb013cb81e0909809818ad6.js). I'd like to match these files using find. Why does this return 0 results?

find -regex "^[A-f0-9]{32}\.(?:js|css)$"
share|improve this question
Instead of A-f, I guess you either mean a-f, or A-Fa-f. – user unknown May 4 '12 at 19:50
up vote 7 down vote accepted
  • The regular expression is matched against the path, not just the file name, so do not anchor it to the beginning of string.
  • The default emacs type regular expression seems to not like intervals. Choose another.
  • Neither the other regular expression types seem to like the non capturing groups.

These work, supposing you are using GNU find:

find . -regextype posix-awk -regex ".*/[a-f0-9]{32}\.(js|css)$"

find . -regextype posix-basic -regex ".*/[a-f0-9]\{32\}\.\(js\|css\)$"

find . -regextype posix-egrep -regex ".*/[a-f0-9]{32}\.(js|css)$"

find . -regextype posix-extended -regex "/[a-f0-9]{32}\.(js|css)$"
share|improve this answer
works perfectly. thank you – code_monk May 4 '12 at 17:31
@sean If it works for you, please consider accepting the answer. – Eugene S May 4 '12 at 20:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.