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>
index | next in thread | previous in thread | raw e-mail
On Jan 12, 2011, at 10:43 AM, Samuel Martín Moro wrote:
> On W
>>
>>>> If I run in the following shell script :
>>>>
>>>> #!/bin/sh
>>>> SD=0
>>>> SD=`ps -ax | grep slapd | grep -v grep | wc -l`
>>>> echo $SD
>>>>
>>>> the result is 3 !!!
>>>>
>>>
>> ps ax | grep "[/]slapd " | wc -l
>>
> ps ax | awk '/[/]slapd /{n++} END{print n}'
> sorry...
>
>> 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.
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C756456F-3B1C-4210-BA40-3A064384A038>
