On Fri, Mar 15, 2019 at 07:52:57AM -0700, Todd Chester via perl6-users wrote:
> 
> 
> On 3/15/19 2:52 AM, Peter Pentchev wrote:
> > 1. Learn to use pgrep instead of the myriad variations of ps | grep;
> >     pgrep has been standardized by POSIX for a long time and is almost
> >     certainly available in all the installations that you will ever need
> >     to touch[1].
> 
> pgrep is interesting!  But it is not listing all the processes.  :'(
> 
> $ pgrep firefox
> 2135
> 
> $ ps ax | grep [f]irefox | awk '{print $1}'
> 2135
> 2239
> 2342
> 2425

So maybe play around with its options a bit; take a look at its manual page.
Also note that "ps ax | grep [f]irefox" (and I would VERY STRONGLY suggest
that you put the argument to "grep" in quotes to avoid the shell interpreting
it in weird and wonderful ways) might also match a process with a different
name that has "firefox" in its list of arguments - actually that's
the crazy reason for the '[f]irefox' hack, since this way the grep process
will not find itself (it's a variation of a "ps ax | grep firefox | grep -v 
grep"
construct that people still seem to want to use).

G'luck,
Peter

-- 
Peter Pentchev  roam@{ringlet.net,debian.org,FreeBSD.org} p...@storpool.com
PGP key:        http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13

Attachment: signature.asc
Description: PGP signature

Reply via email to