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.
pushd . > /dev/null
echo "Counting Spam..."
for i in `ls * -d`; do
MESSAGES=`find $i/Maildir/.Spam | grep anubis`
if [ -z "$MESSAGES" ]
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;
popd > /dev/null
A sample output is this:
5 Spam messages for carsten trapped
1 Spam messages for uwe trapped
I'd really appreciate any idea...