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.  
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to