find . -regex "\./#.*#\|\./.*~"
Does this work for you?
I need to use
-Efor extended regex.
find . -regextype help to learn available options. GNU
find in my Debian supports few. This works:
find . -regextype posix-extended -regex '\./(.*~$|#.*#)'
Note I have debugged and simplified the regex a little (
\./.*~$|\./#.*# would also work). Other options that work for me in this particular case:
find . -regex '\./#.*#\|\./.*~'
| is escaped works for me. Credits to the other answer. Proper escaping of
) makes the following work as well:
find . -regex '\./\(.*~$\|#.*#\)'
without relying on extended regular expressions.
You don’t have to compact the two expressions into one. If these work:
find . -regex '\./.*~' find . -regex '\./#.*#'
then you can get files matching one regex or the other this way:
find . -regex '\./.*~' -o -regex '\./#.*#'
Be warned: Why does
find in Linux skip expected results when
-o is used? If you want to add more tests/actions before and/or after then you don’t want this:
find . -test1 -test2 -regex '\./.*~' -o -regex '\./#.*#' -test3 …
find . -test1 -test2 '(' -regex '\./.*~' -o -regex '\./#.*#' ')' -test3 …