Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

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'm trying to set up a function to make certain grep command easier.

gr() { grep -r --include=*.\{m,h,xib\} $1 \* ; }

The end result should be a recursive grep of all *.m, *.h, and *.xib files, for whatever is specified by the command's argument:

$ gr SearchText

Can anyone demonstrate the correct syntax for this?

share|improve this question
up vote 3 down vote accepted

Nevermind; thought I had tried everything I could imagine; turns out I was just over-zealous with escaping special characters from the shell. The syntax I was looking for is:

gr() { grep -r --include=*.{m,h,xib} "$1" * ; }
share|improve this answer
Make sure you accept your answer when you can. – daviesgeek Oct 19 '11 at 18:29

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.