Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 33 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
4  
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
add comment

Your Answer

 
discard

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.