On Tuesday 07 September 2004 6:26 am, Bob Apthorpe wrote: > > The file as it is now running, or not, is: > > > > #! /bin/bash > > DEFFILES="/etc/mail/spamassassin/*.cf" > > GREPSTR="describe" > > cat $DEFFILES | egrep ^$GREPSTR \ > > > > | awk '{ print "echo `fgrep " $2 "/home/robbo/.Mail/SpamPile/cur/ \ > > | wc -l` " $2 } ' | sort | uniq | tail +2 | sh | sort -rn > > > > #EOF > > Why not: > > #! /bin/bash > DEFFILES="/etc/mail/spamassassin/*.cf" > GREPSTR="describe" > MAILFOLDER=/home/robbo/.Mail/SpamPile/cur > egrep "^[ ]*$GREPSTR" $DEFFILES | \ > > | awk '{ print "echo `fgrep " $2 " $MAILFOLDER/* \ | wc -l` " $2 } ' \ > | sort | uniq | tail +2 | sh | sort -rn > > #EOF > > Notes: > > '[ ]' is '[<space><tab>]' - useful for dealing with leading whitespace. > If you really need to get rid of leading whitespace, pipe results of the > egrep through "sed 's/^[ ]*//'" rather than deleting whitespace from > the config files. > > There's a big difference between /home/robbo/.Mail/SpamPile/cur/ and > /home/robbo/.Mail/SpamPile/cur/* and that's probably what's tripping you > up. > > Running the code with 'sh -ax script.sh' helps with debugging shell > scripts.
Yep, it sure did. I still don't know what is wrong, as I don't understand awk at all. But the spaces in the cat line were screwing bash up. I removed all of them between the commads and the pipes, and got it all running. But it would lonly list one rule with no hits. Sigh. I got your spamrulescan.sh running on my machine however, and while it is fairly slow, it got the job done, and I was able to parse the rules back to the original rule files. That would be a great trick, to have it down to the *.cf file that triggered the hit, so everything is numbered by the rule that tripped it to make tuning filters easier. Rob -- Linux Desktop user since 2000, Home networker since shortly after. Linux User #183693 http://counter.li.org/