Training scripts
Matej Cepl
cepl at surfbest.net
Wed Jan 28 02:08:19 CET 2004
On Tuesday 27 of January 2004 17:55, Fred Yankowski wrote:
> My feeling is that you are trying to do too much inside 'find'
> itself.
> I prefer to feed the output of 'find' into 'xargs' or into a
shell
> 'while' loop:
>
> find $MAILDIR -type f -print |
> while read MAILFILE; do
> STR=$(basename $MAILFILE)
> echo $STR
> ... whatever else ...
> done
Thanks! Yes, 'read' command is an Achilles heal of my bash skills
:-). This is what I did and what seems to work fine:
#!/bin/sh
#$Id: bgf,v 1.2 2004/01/28 01:01:57 matej Exp matej $
MAILDIR=$HOME/.mail
find $MAILDIR/_spam/ -type f -name 10\* \
| while read msg; do
formail -I X-Bogosity -I X-KMail \
-s bogofilter -vs < $msg
STR=$(basename $msg)
mv $msg $MAILDIR/_junk/new/${STR%*:2,S}
done
find $MAILDIR/_ham/ -type f -name 10\* \
| while read msg; do
formail -I X-Bogosity -I X-KMail \
-s bogofilter -vn < $msg
STR=$(basename $msg)
mv $msg $MAILDIR/inbox/new/${STR%*:2,S}
done
Thanks,
Matej
--
Matej Cepl, http://www.ceplovi.cz/matej
GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC
138 Highland Ave. #10, Somerville, Ma 02143, (617) 623-1488
America is the only country that has gone from barbarism to
decadence without civilization in between.
-- Oscar Wilde
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
URL: <http://www.bogofilter.org/pipermail/bogofilter/attachments/20040127/116c2c6f/attachment.sig>
More information about the Bogofilter
mailing list