grep'ping the ps output....

Eric Schuele e.schuele at computer.org
Tue Dec 13 07:21:51 PST 2005


Sergey Zaharchenko wrote:
> Hello Eric!
> 
> Mon, Dec 12, 2005 at 10:04:51AM -0600 you wrote:
> 
> 
>>I was wondering if someone could explain why it is sometimes there and 
>>not other times.
> 
> 
> Sometimes the ps process manages to catch the system state when grep has
> not been started yet by the shell. Sometimes it doesn't.
> 
> 
>>And how I should correctly go about detecting if the 
>>process is running before I perform my action.
> 
> 
> You may use the -c flag of ps:
> 
>      -c      Change the ``command'' column output to just contain the exe-
>              cutable name, rather than the full command line.
> 
> Like:
> 
> df at shark:~> ps axc |grep init
>     1  ??  ILs    0:00,00 init
> 

Yes... Of course.  That's the solution I'm looking for.

Good thing I read over that man page before I posted my msg... Or I 
could've embarrassed myself.  :}

Thanks.

-- 
Regards,
Eric


More information about the freebsd-questions mailing list