Hi everyone,
I just wrote a small shell script to count all the spam I trapped using my spamassassin. Herein I also print the spam-count from each message.
Now I would like to add the sum to the output but I'm not really sure how to do this.
In the past I sometimes used "bc" for arithmetic operations in my scripts. But I havo no idea how to add it here.
This is the code I have atm, you are free to copy any part if you find it of any use to you.
Code:
#!/bin/sh
pushd . > /dev/null
cd /home/profiles
echo "Counting Spam..."
for i in `ls * -d`; do
MESSAGES=`find $i/Maildir/.Spam | grep anubis`
if [ -z "$MESSAGES" ]
then
continue
fi
COUNT=`echo $MESSAGES | wc -w`
echo $COUNT Spam messages for $i trapped;
for i in $MESSAGES; do
grep -h "Content analysis details" $i | cut -d : -f 2 | cut -d , -f 1 | cut -d \( -f 2;
done
done
popd > /dev/null
A sample output is this:
Code:
5 Spam messages for carsten trapped
8.10 points
9.60 points
8.40 points
6.90 points
14.70 points
1 Spam messages for uwe trapped
9.70 points
I'd really appreciate any idea...
Greetings
Marcus