Date: Fri, 20 Jun 2003 16:34:57 +0100 From: Matthew Seaman <m.seaman@infracaninophile.co.uk> To: Warren Block <wblock@wonkity.com> Cc: FreeBSD Questions <freebsd-questions@freebsd.org> Subject: Re: IPFW Log question Message-ID: <20030620153457.GA2304@happy-idiot-talk.infracaninophile.co.uk> In-Reply-To: <20030620081951.G12793@wonkity.com> References: <20030620130049.63710.qmail@web10002.mail.yahoo.com> <20030620134326.GA615@happy-idiot-talk.infracaninophile.co.uk> <20030620081951.G12793@wonkity.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
On Fri, Jun 20, 2003 at 08:21:52AM -0600, Warren Block wrote:
> On Fri, 20 Jun 2003, Matthew Seaman wrote:
>
> > > 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 = "";
> >
> > while (<>) {
> > if (m/last message repeated (\d+) times/) {
> > for ( 1 .. $1 ) {
> > print $prevline;
> > }
> > } else {
> > print $_;
> > $prevline = $_;
> > }
> > }
>
> If I read that right, this would also work:
>
> #!/usr/bin/perl -w
>
> while (<>) {
> print $_ unless $_ =~ /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.43.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.43.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.43.65.87:4321 out via de0
Jun 20 16:26:02 example /kernel: ipfw: 800 Deny TCP 12.34.56.78:1234 21.43.65.87:4321 out via de0
Jun 20 16:26:02 example /kernel: ipfw: 800 Deny TCP 12.34.56.78:1234 21.43.65.87:4321 out via de0
Of course, on closer reading, your code is exactly what the OP asked for.
Cheers,
Matthew
--
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
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)
iD8DBQE+8ymhdtESqEQa7a0RAhR6AKCDqpWm4KD7x/P40+EyxZ0cNklF3gCbBSct
YV0QV2p5zq2q5pGJjCOwDrg=
=YzQ3
-----END PGP SIGNATURE-----
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030620153457.GA2304>
