[Novalug] More on spam-fighting
DonJr
djr1952 at hotpop.com
Fri Mar 7 19:49:16 EST 2008
On Fri, 2008-03-07 at 12:18 -0500, rosejw at cox.net wrote:
> ---- Paul <unix at bikesn4x4s.com> wrote:
> > On Fri, March 7, 2008 11:12 am, DonJr wrote:
> > > On Fri, 2008-03-07 at 09:58 -0500, unix at bikesn4x4s.com wrote:
> > >> On Fri, March 7, 2008 4:02 am, DonJr wrote:
> > >> > On Fri, 2008-03-07 at 01:40 -0500, unix at bikesn4x4s.com wrote:
> > >> >> On Wed, March 5, 2008 11:33 pm, DonJr wrote:
> > >> >> > On Wed, 2008-03-05 at 22:02 -0500, Paul wrote:
> > >> >> >> On Mon, March 3, 2008 1:30 pm, David A. Cafaro wrote:
> > >> >> >> > You make the change in your main.cf file (for postfix):
> > >> >> >> >
> > >> > <SNIP see archives>
> > >> > Then how about
> > >> > VAR=$(grep -c 'reject.*Mar [4-5]' maillog | sed 's/\ /\n/g');
> > >> > echo $VAR | grep --count zen.spamhaus.org;
> > >> > echo $VAR | grep --count dnsbl.sorbs.net;
> > >> >
> > >> > "man grep"
> > >> > -c, --count
> > >> > Suppress normal output; instead print a count of matching lines
> > >> > for each input file.
> > >> >
> > >> >
> > >> > And yes I do type lines like this in on the fly at times.
> > >>
> > >> OK, rub it in. I'll be there some day. Thanks for that one, I like it.
> > >> I missed that one, Was doing all kind of man pages last night, lol.
> > >> OK,
> > >> now off to my virtual class...
> > >
> > > Except that last grep version has an ERROR and would always output only:
> > > 0
> > > 0
> > >
> > > Can anyone see why? <GRIN>
> >
> > The asterisk within the tics? Haven't tried it yet.
> No, the first grep -c that defines $VAR will assign a number to $VAR,
> therefore the subsequent greps won't find anything, therefore wc -l will output 0.
You are correct other then the grep option '--count' replaces the need
to pass the output through 'wc' to get a count of the number of hits in
the log.
I should of said:
VAR=$(grep 'reject.*Mar [4-5]' maillog | sed 's/\ /\n/g');
echo $VAR | grep --count zen.spamhaus.org;
echo $VAR | grep --count dnsbl.sorbs.net;
To others notice that the 'VAR=$(grep' line is now missing a '-c'.
For others in "regular expressions" who said about the 'space'
'.' means match ANY Character (including the space)
'*' means match 0 or more of the proceeding characters
So the sequence '.*' means match 0 or more of any sequences of
characters.
See: man regex
--
DonJr
More information about the Novalug
mailing list