Quoting Michael Sims <[EMAIL PROTECTED]>:

> [EMAIL PROTECTED] wrote:
> > A quick note.  If you are grepping the output of a ps command,
> > enclose the first character of your regexp in square brackets.  For
> > example:
> >
> > ps aux | grep [l]pr
> >
> > This still lists all the processes that contain the string "lpr", but
> > it will not match the grep process itself anymore.
> 
> Why is that?  Isn't a bracket expression containing only one character
> exactly the
> same as the character by itself?  Am I missing something blindingly obvious?
> :)
> 

As you point out, the brackets with one character amount to a range of one
character.  The "[l]pr" regexp is intrepreted as "lpr", but the grep command
show up in ps as "grep [l]pr".  This prevents grep from matching its own
process as it is output by ps.

-Roberto Sanchez

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to