From owner-freebsd-questions@FreeBSD.ORG Wed Jan 12 15:58:37 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E927E1065670 for ; Wed, 12 Jan 2011 15:58:36 +0000 (UTC) (envelope-from dscheidt@panix.com) Received: from www.thixotropy.net (vc183.vc.panix.com [IPv6:2001:470:30:80:e276:63ff:fe62:3833]) by mx1.freebsd.org (Postfix) with ESMTP id A67F48FC22 for ; Wed, 12 Jan 2011 15:58:36 +0000 (UTC) Received: from [IPv6:2001:470:c399:1:217:f2ff:fe3f:2ccd] (unknown [IPv6:2001:470:c399:1:217:f2ff:fe3f:2ccd]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by www.thixotropy.net (Postfix) with ESMTPSA id 16F6D1257E5 for ; Wed, 12 Jan 2011 10:58:35 -0500 (EST) References: <4D2DB449.6070901@esiee.fr> In-Reply-To: Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=iso-8859-1 Message-Id: Content-Transfer-Encoding: quoted-printable From: David Scheidt Date: Wed, 12 Jan 2011 10:58:33 -0500 To: User Questions X-Mailer: Apple Mail (2.1082) Subject: Re: problem with shell script X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2011 15:58:37 -0000 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=