4

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.

2 Answers 2

4

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,\}' 
1
  • 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 :-) Commented Nov 17, 2010 at 22:27
2

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.