Date: Wed, 26 Sep 2001 08:17:19 +0200 From: Cliff Sarginson <cliff@raggedclown.net> To: FreeBSD Questions <freebsd-questions@FreeBSD.ORG> Subject: Re: if then statement with grep Message-ID: <20010926081719.D3574@raggedclown.net> In-Reply-To: <XFMail.20010925210314.conrads@home.com>; from conrads@home.com on Tue, Sep 25, 2001 at 09:03:14PM -0500 References: <20010926111238.C99595@k7.mavetju.org> <XFMail.20010925210314.conrads@home.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010926081719.D3574>
