[news.software.b] expire & awk script

alan@km4ba.uucp (Alan Barrow) (06/27/91)

adeboer@gjetor.geac.COM (Anthony DeBoer) writes:

stuff deleted....
>should be taken or not.  You could either write a series of explist files
>manually, calling them explist.1, explist.2, and so on, each reflecting one
>pass of your algorithm, or write a program (which could be an awk script) to
>generate the n-th version from a master file containing additional parameters.

Something I cooked up one night:
#----------------------------------------------------------------------------
#!/bin/sh
#    Written by Alan Barrow. Use, copy, mutilate freely! :-)
awk '\
/^#/    {print $0 } \
/^\//   { print $0 } \
/^[a-z]/\
{ \
        if ( $1 == "all" )
        {\
                if ( $3 >= 2 ) \
                        $3=$3/2;
                printf "%-30s\t%1s\t%d\t%s\n", $1 ,$2, $3 ,$4  \
        }\
        else
        {\
                if ( $3 >= 8 ) \
                        $3=$3/2;
                printf "%-30s\t%1s\t%d\t%s\n", $1 ,$2, $3 ,$4  \
        }\
} \
' $1
#-----------------------------------------------------------------------------

This script accepts one parameter, a cnews format explist file. (path fully
qualified) It then divides the previous expire date for a group by 2 if
it is greater than a certain amount. (sending the output to stdout) 
There are two cases; all & individual groups.

You could do operations other than divide by 2, as well.

my master expire script runs one normal expire, using the original
explist file. It then checks space, processes explist with the above
script, then calls expire again. I hard limit the number of times it runs, as
it usually does not have to run more than once, and I can kick in reap if 
needed.

This is much faster than using reap by itself, for the reasons discussed
before.

Note: I make no claim to have tested all possible explists on this.
It does work for entries like the following:
     rec.boats,alt.fishing           x       14       -
     all                             x        3       -

It should not effect any other field but the 3rd, anyway. Spaces are
not legal between newsgroups, but this may be true for expire as well.


works for me!!! Let us know if you develop a better/neater versions of this.

Good Luck!


 Alan Barrow  km4ba | I've seen things you people wouldn't believe. Attack
 jab@hpuerca.hp.com | ships on fire off the shoulder of Orion. I watched
                    | C-beams glitter in the dark near the Tannhauser gate.
 ..!gatech!kd4nc!   | All those moments will be lost in time -
         km4ba!alan | like tears in rain. Time to die.          Roy Batty

henry@zoo.toronto.edu (Henry Spencer) (06/27/91)

In article <1991Jun27.055051.7580@km4ba.uucp> alan@km4ba.uucp (Alan Barrow) writes:
>It should not effect any other field but the 3rd, anyway. Spaces are
>not legal between newsgroups, but this may be true for expire as well.

Correct; any white space is a field separator in explist.
-- 
"We're thinking about upgrading from    | Henry Spencer @ U of Toronto Zoology
SunOS 4.1.1 to SunOS 3.5."              |  henry@zoo.toronto.edu  utzoo!henry