From owner-freebsd-questions@FreeBSD.ORG Fri Jun 20 08:35:20 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EA9AA37B401 for ; Fri, 20 Jun 2003 08:35:19 -0700 (PDT) Received: from smtp.infracaninophile.co.uk (happy-idiot-talk.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3282543F3F for ; Fri, 20 Jun 2003 08:35:18 -0700 (PDT) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost [127.0.0.1]) h5KFYvo2002467 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 20 Jun 2003 16:35:13 +0100 (BST) (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)h5KFYvFg002466; Fri, 20 Jun 2003 16:34:57 +0100 (BST) (envelope-from matthew) Date: Fri, 20 Jun 2003 16:34:57 +0100 From: Matthew Seaman To: Warren Block Message-ID: <20030620153457.GA2304@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , Warren Block , Ronnie Clark , FreeBSD Questions References: <20030620130049.63710.qmail@web10002.mail.yahoo.com> <20030620134326.GA615@happy-idiot-talk.infracaninophile.co.uk> <20030620081951.G12793@wonkity.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qMm9M+Fa2AknHoGS" Content-Disposition: inline In-Reply-To: <20030620081951.G12793@wonkity.com> User-Agent: Mutt/1.5.4i X-Spam-Status: No, hits=-11.0 required=5.0 tests=AWL,BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,PGP_SIGNATURE_2, REFERENCES,REPLY_WITH_QUOTES,USER_AGENT_MUTT autolearn=ham version=2.55 X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) cc: Ronnie Clark cc: FreeBSD Questions Subject: Re: IPFW Log question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jun 2003 15:35:20 -0000 --qMm9M+Fa2AknHoGS Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jun 20, 2003 at 08:21:52AM -0600, Warren Block wrote: > On Fri, 20 Jun 2003, Matthew Seaman wrote: >=20 > > > Or if anyone has a perl script that tosses out the odd > > > lines and just keeps the full lines and is willing to > > > share it, that would work too. Otherwise, I am going > > > to have to get better at perl in a big way. > > > > #!/usr/bin/perl -w > > > > $prevline =3D ""; > > > > while (<>) { > > if (m/last message repeated (\d+) times/) { > > for ( 1 .. $1 ) { > > print $prevline; > > } > > } else { > > print $_; > > $prevline =3D $_; > > } > > } >=20 > If I read that right, this would also work: >=20 > #!/usr/bin/perl -w >=20 > while (<>) { > print $_ unless $_ =3D~ /last message repeated (\d+) times/; > } That's not quite the same thing. You're just taking out the lines that match /last message repeated \d+ times/ (and constructing a backreference to \d+ that you never use): Jun 20 16:26:02 example /kernel: ipfw: 800 Deny TCP 12.34.56.78:1234 21= =2E43.65.87:4321 out via de0 Jun 20 16:26:27 example last message repeated 2 times becomes: Jun 20 16:26:02 example /kernel: ipfw: 800 Deny TCP 12.34.56.78:1234 21= =2E43.65.87:4321 out via de0 whereas I'm replacing that line with the correct number of repeats of the original line, so the example becomes: Jun 20 16:26:02 example /kernel: ipfw: 800 Deny TCP 12.34.56.78:1234 21= =2E43.65.87:4321 out via de0 Jun 20 16:26:02 example /kernel: ipfw: 800 Deny TCP 12.34.56.78:1234 21= =2E43.65.87:4321 out via de0 Jun 20 16:26:02 example /kernel: ipfw: 800 Deny TCP 12.34.56.78:1234 21= =2E43.65.87:4321 out via de0 Of course, on closer reading, your code is exactly what the OP asked for. Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way PGP: http://www.infracaninophile.co.uk/pgpkey Marlow Tel: +44 1628 476614 Bucks., SL7 1TH UK --qMm9M+Fa2AknHoGS Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (FreeBSD) iD8DBQE+8ymhdtESqEQa7a0RAhR6AKCDqpWm4KD7x/P40+EyxZ0cNklF3gCbBSct YV0QV2p5zq2q5pGJjCOwDrg= =YzQ3 -----END PGP SIGNATURE----- --qMm9M+Fa2AknHoGS--