Server Fault is a question and answer site for system and network administrators. 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've seen several instances where people are doing this:

grep [f]oobar

But I don't understand why that is preferable to

grep foobar
share|improve this question
Hmm .. I thought it is supposed to match range of characters within the []. If it is just a single character, it could be just to make it look complicated :) Maybe there is something more to it. – Chida Aug 22 '12 at 19:45
Something so simple can be so beautiful – Chida Aug 22 '12 at 19:55
up vote 32 down vote accepted

There's no reason that's preferable syntax on its own. It's sometimes used as a hack when "grepping" for a process (e.g., ps aux | grep [a]pache). Using that syntax prevents grep from matching its own command line in the process list.

See How to prevent "ps" reporting its own process?

share|improve this answer
That's the only common example of that syntax I'm familiar with. – ewwhite Aug 22 '12 at 19:57
In fact, you are right. The last several examples I ran across were from a "ps exclusion" – hortitude Aug 23 '12 at 15:39

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.