I want to use regex to find all coredump files under a directory. The pattern of the file name is core.1234
find /public_html -type f -regextype sed -regex "core.{[0-9]+:[0-9]+}"
Please advice.
You missed some info on how -regex works
-regex pattern
File name matches regular expression pattern. This is a match on the whole path, not a search. For example, to match a file named./fubar3', you can use the regular expression
.*bar.' or.*b.*3', but not
f.*r3'. The regular expressions understood by find are by default Emacs Regular Expressions, but this can be changed with the -regextype option
In particular the regex needs to match the whole path. You don't need to change the regex type or even supply a -regex
find /public_html -name "core.[0-9][0-9][0-9][0-9]"
does the trick and will find core files at any level below /public_html.
/public_html is part of the path, so try find /public_html -type f -regextype sed -regex ".*/core.{[0-9]+:[0-9]+}"
find /public_html -type f -regextype sed -regex "/public_html/core.[0-9]\+"
EDIT: Added example
$ ls public_html/
core.asdd core.1asd core.123 core.1234 core.12362 core.1456 core.8452
$ find /public_html -type f -regextype sed -regex "/public_html/core.[0-9]\+"
/public_html/core.123
/public_html/core.1234
/public_html/core.1456
/public_html/core.12362
/public_html/core.8452