[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash, expressions, ???



05.01.2003 21:23:16, "Egor Tur" <worldeb@ukr.net> wrote:
>Hi.
>Who can explain?
>ps ax | grep lpd
>  398 ?        S      0:00 lpd Waiting  
> 5593 pts/13   S      0:00 grep lpd
>ps ax | grep [l]pd
>  398 ?        S      0:00 lpd Waiting
>
>What do [l]?

That is more a grep question than a a bash question.
grep has a special meaning for [...], i.e match any
character found inside the brackets (also known as
character class).
So "grep [l]pd" will match "lpd" but not "[l]pd" and
thus leave out the match for grep itself.

Nice trick. I usually used
ps ax | grep lpd | grep -v grep
but with that trick, I can shortcut things from now on.

HTH, Michael






Reply to: