I want find mail files in user maildir, without mailfilter, dovecot-index etc.

All mail files have unix timestamp in its filenames, I think it is the easiest way.

I used this regex: .*\/\d{10}\..*. It working good in http://regexr.com/ tester, but not working in find command string.

Full command string: find /var/lib/exim4/mail/markelov -regextype sed -regex '.*\/\d{10}\..*' -type f

Bracket escaping (.*\/\d\{10\}\..*) not working also.

String examples: Should find:


Shouldn't find:


find --version

find (GNU findutils) 4.4.2
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Eric B. Decker, James Youngman, and Kevin Dalley.
Built using GNU gnulib version e5573b1bad88bfabcda181b9e0125fb0c52b7d3b
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS() CBO(level=0) 

The problem is the \d which is not understood by the sed regex so you should use a character class of digits: [0-9]. Also, sed braces for this use require preceding backslashes. Instead of:




If you instead specify -regextype posix-egrep you would use:


There are many different versions of regular expressions. I would advise you to find the documentation on the command that you're using to find the correct regex syntax.

From the regxr.com website:

RegExr uses your browser's RegExp engine for matching, and its syntax highlighting and documentation reflect the JavaScript RegExp standard.

Which partly explains why the regex didn't work with find.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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