Neil Conway <nconway(at)klamath(dot)dyndns(dot)org> writes:
> On Fri, Feb 16, 2001 at 02:09:42PM -0500, Bryan White wrote:
>> ps ax | grep postgres | wc -l
>> Note the value is often one to high because is picks up the grep process.
> Why not just remove 'grep' - i.e
> ps ax | grep postgres | grep -v grep | wc -l
Actually this is a standard problem with a standard solution: use a
not-so-literal grep pattern, eg
ps ax | grep '[p]ostgres' | wc -l
This pattern matches 'postgres' but not '[p]ostgres'. Problem solved.
regards, tom lane