Help or feature request

Ed Blackman ed at edgewood.to
Mon Sep 7 15:31:22 CEST 2009


On Mon, Sep 07, 2009 at 09:49:47AM +0200, Matthias Andree wrote:
>Am 07.09.2009, 04:31 Uhr, schrieb Орлов Олег <oo at nio.ru>:
>> -t (top, just for example) _number_
>> displays only tokens which position in sorteg by age list (from newer to
>> oldiest) less or equal of _number_
>>
>> It wold be very suitable to effectively limit DB size of users which
>> activity in not very regular or in some other cases.
>
>This is Unix or Linux - you can use bogoutil to dump to a text file, sort  
>it (with -k parameter), cut it and then move the existing database to a  
>separate directory (as backup) and finally use bogoutil to reload the  
>database today -- no need to add code to bogoutil.

This should do the trick:

#!/bin/sh

db="$1"
top="$2"

# error if the bogofilter database doesn't exist
if [ ! -e "$db" ]; then
   echo "Usage: $0 <db> <count>" >&2
   exit 1
fi

# error if no count is given
if [ -z "$top" ]; then
   echo "Usage: $0 <db> <count>" >&2
   exit 2
fi

# filter the <count> most recent entries into a temp db
bogoutil -d "$db" | sort -rk 3 | head -$count | bogoutil -l "$db.tmp"

# if the temp db exists and can be dumped, replace the original
if [ -s "$db.tmp" ] && bogoutil -d "$db.tmp" >/dev/null; then
   mv "$db.tmp" "$db"
fi

Ed
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.txt
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://www.bogofilter.org/pipermail/bogofilter/attachments/20090907/9ec6f99c/attachment.sig>


More information about the Bogofilter mailing list