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

I've two files in the current folder:


the following find does not show the two files:

find . -regex .*submit\(Web\)?\.m

But the above regex expression works fine in emacs buffer, i.e., search for the example strings in the emacs buffer using isearch-forward-regexp.

The default regextype for find is emacs.

But it seems that find consider \( as a left bracket in the filename, which differs from emacs regex syntax.

So is this a bug or my misunderstanding of find manpage?

share|improve this question
up vote 5 down vote accepted

It seems that the problem is \( is interpreted by the shell first.

For example, you got a file in the current directory named:



ls foo\(.text


ls "foo(.text"

both work.

So, the following works:

find . -regex ".*submit\(Web\)?\.m"


Single quote also works here.

Difference between single quote and double quote, see this post: single quote vs double quote in bash

share|improve this answer
Or put the regex in single quotes instead: find . -regex '.*submit\(Web\)?\.m' – slm May 26 '13 at 1:44
@slm Yes, anyway, just prevent the shell from interpreting the \(. Edited. – gongzhitaao May 26 '13 at 4:08
A good rule of thumb is to quote everything in single quotes unless you specifically need the substitution behavior of double quotes. – tripleee May 26 '13 at 11:28
@tripleee Thank for reminding. Edited. – gongzhitaao May 26 '13 at 14:42

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.