[TriLUG] Re: command line: delete all mail in a folder

James Manning jmm at sublogic.com
Tue Sep 30 04:42:17 EDT 2003


> Ive considered just deleting the entire file and using touch
> to recreate an empty mbox folder, but there must be a more elegant
> and safe way.

I'm sure there's better routes, but this is what I have for a daily
cron job - answer to the orig. question being "cp /dev/null foo"


jmm at sublogic:/home/jmm% less bin/process_spam.sh
#!/bin/sh

PATH=/usr/bin:/bin
SPAM_MBOX=~/mail/spam
HAM_MBOX=~/mail/ham

if [ -s $SPAM_MBOX ]; then
    sa-learn --spam --mbox $SPAM_MBOX
    cp /dev/null $SPAM_MBOX
fi
if [ -s $HAM_MBOX ]; then
    sa-learn --ham --mbox $HAM_MBOX
    cp /dev/null $HAM_MBOX
fi
sa-learn --rebuild

-- 
James Manning <http://www.sublogic.com/james/>
GPG Key fingerprint = B913 2FBD 14A9 CE18 B2B7  9C8E A0BF B026 EEBB F6E4



More information about the TriLUG mailing list