Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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

My Samsung Galaxy S doesn't like files where the name contains a long string after the first dot. I guess some part of the software has a too short buffer for the file extension. How can I find all files on my Micro-SD-Card mounted at /media/sd where the filename has more than five characters after the first dot?

Reading the find manpage, I thought

find . -regex '.*\..\{5,\}'

would work, but it doesn't give any hits, so I somehow don't get my regular expression right.

share|improve this question
up vote 4 down vote accepted

The problem is that the default type of regex's used by find is emacs-style. Find's documentation for emacs style regexes doesn't include the \{n,\} construction--leading me to believe that it isn't supported in find's implemenation of emacs-style regular expressions. The emacs-wiki lists this as valid, however it is possible that this wasn't always the case.

I found that your regex produced output if you do this:

$ find . -regextype posix-basic -regex '.*\..\{5,\}'
share|improve this answer
Yes, this indeed works. As an Emacs user who knows the \{\} syntax, I didn't bother to look up finds emacs regex syntax as I assumed it would be the same. Shame on me for being so full of trust for GNU :-) – fschmitt Nov 17 '10 at 22:27

Braces are not always included in basic regexp implementations. I don't know if you have GNU find or Busybox find; Busybox may not have all the features of GNU find.

A portable way to search for files with a long extension is find . -name '*.?????*'.

Note that your regexp would match most files under a directory whose name contains a dot.

share|improve this answer

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.