Super User is a question and answer site for computer enthusiasts and power users. 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 find single exclude extension like

grep --exclude "*.js" "a" *

How do I write multiple exclude masks?

I have tried the code below, but it doesn't work:

grep -r --exclude=*.\{html,htm,js} "li" *

grep -R -E '(\.js|rb)' "create" * 
share|improve this question
up vote 3 down vote accepted

You should escape the asterisk, not the curly brace. Your command should look like this:

grep -r --exclude=\*.{html,htm,js} "li" *
share|improve this answer

man grep *scroll scroll scroll*

          Skip files whose base name matches GLOB (using wildcard  matching).
          A  file-name  glob  can use *, ?, and [...]  as wildcards, and \ to
          quote a wildcard or backslash character literally.

Look up "shell globbing" for more info


$ grep -r  --exclude=\*.{png,jpg} a .

$ ls
hai  hai.png  moo.htm  moo.txt

Similar question

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.