Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 May 2002 09:44:18 +0100
From:      Brian Somers <brian@Awfulhak.org>
To:        cjclark@alum.mit.edu
Cc:        Giorgos Keramidas <keramida@freebsd.org>, freebsd-audit@freebsd.org, Brian Somers <brian@freebsd.org>, Doug Barton <dougb@freebsd.org>, Gregory Neil Shapiro <gshapiro@freebsd.org>, Robert Watson <rwatson@freebsd.org>, brian@Awfulhak.org
Subject:   Re: Removing perl traces from src/etc/periodic 
Message-ID:  <200205310844.g4V8iIEU024730@hak.lan.Awfulhak.org>
In-Reply-To: Message from "Crist J. Clark" <crist.clark@attbi.com>  of "Wed, 29 May 2002 11:29:22 PDT." <20020529112922.A12700@blossom.cjclark.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
> On Wed, May 29, 2002 at 06:20:10PM +0300, Giorgos Keramidas wrote:
> 
> [snip]
> 
> > Index: etc/periodic/security/550.ipfwlimit
> > ===================================================================
> > RCS file: /home/ncvs/src/etc/periodic/security/550.ipfwlimit,v
> > retrieving revision 1.3
> > diff -u -r1.3 550.ipfwlimit
> > --- etc/periodic/security/550.ipfwlimit	17 May 2002 11:34:12 -0000	1.3
> > +++ etc/periodic/security/550.ipfwlimit	28 May 2002 20:57:21 -0000
> > @@ -45,8 +45,10 @@
> >      [Yy][Ee][Ss])
> >  	IPFW_LOG_LIMIT=`sysctl -n net.inet.ip.fw.verbose_limit 2> /dev/null`
> >  	if [ $? -eq 0 ] && [ "${IPFW_LOG_LIMIT}" -ne 0 ]; then
> > -	    ipfw -a l | grep " log " | perl -n -e \
> > -		'/^\d+\s+(\d+)/; print if ($1 >= '$IPFW_LOG_LIMIT')' > ${TMP}
> > +	    ipfw -a l | grep " log " | \
> > +	    grep '^[[:digit:]]\+[[:space:]]\+[[:digit:]]\+' | \
> > +	    awk -v limit="$IPFW_LOG_LIMIT" \
> > +		'{if ($2 > limit) {print $0}}' > ${TMP}
> 
>   +	    ipfw -a l |
>   +	    awk -v limit="$IPFW_LOG_LIMIT" \
>   +		'/ log / && /^[[:digit:]]+[[:space:]]+[[:digit:]]+/ { \
>   +		    if ($2 > limit) {print;} \
>   +		}' > ${TMP}
> 
> For whatever reason, chaining grep(1)s in front of an awk(1) always
> bothers me. It's easy enough to do with one awk(1).

Agreed.  Ditto for sed :)

> -- 
> Crist J. Clark                     |     cjclark@alum.mit.edu
>                                    |     cjclark@jhu.edu
> http://people.freebsd.org/~cjc/    |     cjc@freebsd.org

-- 
Brian <brian@Awfulhak.org>                          <brian.somers@sun.com>
      <http://www.Awfulhak.org>;                   <brian@[uk.]FreeBSD.org>
Don't _EVER_ lose your sense of humour !          <brian@[uk.]OpenBSD.org>



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200205310844.g4V8iIEU024730>