Re: Help or feature request

Ed Blackman <[email protected]>
Newsgroups gmane.mail.bogofilter.general
Message-ID <[email protected]>
On Mon, Sep 07, 2009 at 09:49:47AM +0200, Matthias Andree wrote:
>Am 07.09.2009, 04:31 Uhr, schrieb Орлов Олег <[email protected]>:
>> -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

_______________________________________________
Bogofilter mailing list
[email protected]
http://www.bogofilter.org/mailman/listinfo/bogofilter
signature.txt (application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFKpQsp3nrUNJhVPs4RAqWnAKCD6mnVXcs8PGR90Gyh28zlWlBC0QCeJpKv
Oqc9RZE1a+XalptYfyS2gOA=
=YiXK
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.