Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 12 Jan 2011 10:58:33 -0500
From:      David Scheidt <dscheidt@panix.com>
To:        User Questions <freebsd-questions@freebsd.org>
Subject:   Re: problem with shell script
Message-ID:  <C756456F-3B1C-4210-BA40-3A064384A038@panix.com>
In-Reply-To: <AANLkTinkSOUm84RamXn8qToxb5YQG%2BH6VwOtKZJVy7nN@mail.gmail.com>
References:  <4D2DB449.6070901@esiee.fr> <AANLkTimHU7kQXM0agHsfz=hHn2zuBuL4xihDxUWo3%2BvB@mail.gmail.com> <AANLkTikcH9jjNNf-1vwTzgxekH5bp%2BdXnnvh923f1NcM@mail.gmail.com> <AANLkTinkSOUm84RamXn8qToxb5YQG%2BH6VwOtKZJVy7nN@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On Jan 12, 2011, at 10:43 AM, Samuel Mart=EDn Moro wrote:

> On W
>>=20
>>>> If I run in the following shell script :
>>>>=20
>>>> #!/bin/sh
>>>> SD=3D0
>>>> SD=3D`ps -ax | grep slapd | grep -v grep | wc -l`
>>>> echo $SD
>>>>=20
>>>> the result is 3 !!!
>>>>=20
>>>=20
>> ps ax | grep "[/]slapd " | wc -l
>>=20
> ps ax | awk '/[/]slapd /{n++} END{print n}'
> sorry...
>=20
>> may not fix the problem
>> but still cleaner


ps ax | grep [s]lapd | wc -l

The [] creates a one-character class that doesn't match the regex.  =
Easier to type and grep should be a bit faster. =20=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C756456F-3B1C-4210-BA40-3A064384A038>