#! /bin/sh #-------------------------------------------------------------------------- # Script to train SpamAssassin from the supplied mbox file and then # delete the messages. #-------------------------------------------------------------------------- salearnBin="/usr/bin/vendor_perl/sa-learn" mailFolder=$1 # Date stamp the output echo -n "$(date +"%F %T")> " # Train SpamAssassin with the mail in the supplied folder #$salearnBin --spam --mbox --no-rebuild $mailFolder $salearnBin --spam --mbox $mailFolder # Remove the spam from the folder mailFolderNew=${mailFolder}.new awk '/^From / { messages++ }; messages > 1 { exit 0 }; { print }' $mailFolder > $mailFolderNew if [ -e $mailFolderNew ] then rm $mailFolder mv $mailFolderNew $mailFolder fi