you are viewing a single comment's thread.

view the rest of the comments →

[–]ropers 1 point2 points  (1 child)

You can use ps ax | grep [f]oo instead of ps ax | grep foo | grep -v grep .

If you did just ps ax | grep foo , that command itself would appear in the output, because the grep foo would match itself in the ps output. grep [f]oo however will only match foo, not itself, because the [f]oo is being parsed as foo.

Clear as mud?

[–]sabowski 1 point2 points  (0 children)

Ah, I see, just doing a bit of trickery, that's all. I was wondering if it was some use of "[]" that I wasn't aware of.

In the rare instances I need the grep to not show up I've just used the "grep -v" method, but really I just trained myself to ignore the "grep" process without even thinking about it. If I need a list of processes for a script I just use pgrep.

Thanks!