From owner-freebsd-questions Tue Sep 25 23:19:28 2001 Delivered-To: freebsd-questions@freebsd.org Received: from post.mail.nl.demon.net (post-11.mail.nl.demon.net [194.159.73.21]) by hub.freebsd.org (Postfix) with ESMTP id 36AB737B421 for ; Tue, 25 Sep 2001 23:19:21 -0700 (PDT) Received: from [212.238.77.116] (helo=buffy.raggedclown.net) by post.mail.nl.demon.net with esmtp (Exim 3.22 #1) id 15m82Q-000MEZ-00 for freebsd-questions@FreeBSD.ORG; Wed, 26 Sep 2001 06:19:20 +0000 Received: by buffy.raggedclown.net (Ragged Clown Mailhost, from userid 500) id 857CCBD65; Wed, 26 Sep 2001 08:17:19 +0200 (CEST) Date: Wed, 26 Sep 2001 08:17:19 +0200 From: Cliff Sarginson To: FreeBSD Questions Subject: Re: if then statement with grep Message-ID: <20010926081719.D3574@raggedclown.net> References: <20010926111238.C99595@k7.mavetju.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.16i In-Reply-To: ; from conrads@home.com on Tue, Sep 25, 2001 at 09:03:14PM -0500 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, Sep 25, 2001 at 09:03:14PM -0500, Conrad Sabatier wrote: > > On 26-Sep-2001 Edwin Groothuis wrote: > > On Wed, Sep 26, 2001 at 10:56:43AM +1000, BSD Freak wrote: > >> if `grep "expected line" /var/log/mylogfile` does NOT return something > >> then > >> mail -s "Alert" me@mycompany.com > >> otherwise don't bother me > > > > if [ ! -z "`grep "expected line" /var/log/mylogfile`" ]; then > > ... do your stuff here ... > > fi > > Actually, a simple "if ! grep ..." should do the same thing. > Or even grep "expected line" /var/log/mylogfile >/dev/null [ $? -ne 0 ] && { echo "In this house we obey the laws of thermodynamics"; } -- Regards Cliff To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message