On 30 Aug 2014, at 07:49 , LuKreme <krem...@kreme.com> wrote: > MYFIND= `find $H_PATH/cur -type f -mtime -7` > if [ -n $MYFIND ]; then > /usr/local/bin/sa-learn --ham -u ${i} $MYFIND > fi
Doh! if [ -n “$MYFIND” ]; then or if test -n “$MYFIND”; then Sigh. Feeling extra stupid this Saturday morning. It works, and is no longer processing thousands of old messages for no reason. #/bin/sh # # Straightforward shell script to be run as root. This parses the /home # directory for mailboxes named .Junk and learns those as spam, and then # parses the inbox (cur, not new) for ham. # sa-learn-script (sal) v2.1 Lewis Butler, released to the Public Domain 2012 UROOT="/home/" echo "Running SAL" for i in `ls $UROOT` ; do J_PATH="${UROOT}${i}/Maildir/.Junk"; H_PATH="${UROOT}${i}/Maildir”; if test -d "$J_PATH"; then MYFIND=`find $J_PATH/ -type f -mtime -7|grep -v dovecot` if test -n "$MYFIND"; then /usr/local/bin/sa-learn --spam -u ${i} $MYFIND #>/dev/null 2>&1 fi else echo "No $J_PATH for $i" fi if test -d "$H_PATH"; then MYFIND=`find $H_PATH/cur -type f -mtime -7|grep -v dovecot` if test -n "$MYFIND"; then echo "Processing $H_PATH" /usr/local/bin/sa-learn --ham -u ${i} $MYFIND #>/dev/null 2>&1 fi #else # echo "No $H_PATH for $i” fi done If I were feeling really clever, I’d make sure the user existed first, but I’m not feeling that clever today. -- A marriage is always made up of two people who are prepared to swear that only the other one snores.