[sf-lug] shell tip: ps ... | grep ... | grep -v grep
Kristian Erik Hermansen
kristian.hermansen at gmail.com
Fri Jul 4 15:59:44 PDT 2008
You don't need to grep out 'grep' :-) do more people utilize ps aux or ps -e?
On 7/4/08, Michael Paoli <Michael.Paoli at cal.berkeley.edu> wrote:
> While typical Linux distributions have pidof, for greater (e.g.
> UNIX/BSD) portability, often something like:
> ps args | grep 'pattern' | grep -v grep
> is rather commonly used ... e.g. to find the PID(s) running a particular
> program.
>
> Well, a bit more efficient approach would typically be:
> ps args | grep '[p]attern'
>
> How does it work? Well, the RE [p]attern will match pattern, but the ps
> line with grep won't match RE [p]attern, as it will have literal
> argument [p]attern, and thus won't match RE [p]attern.
>
> credits/references:
> Hans Peter Verne, Daniel Robbins
> http://www.ibm.com/developerworks/linux/library/l-keyc3/
>
> _______________________________________________
> sf-lug mailing list
> sf-lug at linuxmafia.com
> http://linuxmafia.com/mailman/listinfo/sf-lug
>
--
Sent from Gmail for mobile | mobile.google.com
Kristian Erik Hermansen
--
CISSP, CEPT, CREA, CEH, Linux+, A+, QGCS, ACSA, this is getting ridiculous...
http://kristian-hermansen.com
More information about the sf-lug
mailing list