On Mon, 6 Sep 2004 18:01:40 -0700 Rob Blomquist <[EMAIL PROTECTED]> wrote:
> On Wednesday 25 August 2004 5:46 am, Jack L. Stone wrote: > > At 10:31 PM 8.24.2004 -0700, Loren Wilton wrote: > > >> > #!/bin/sh > > >> > DEFFILES="/etc/mail/spamassassin/*.cf" > > >> > GREPSTR="describe" > > >> > > > >> > cat $DEFFILES | egrep ^$GREPSTR \ > > >> > > > >> > | awk '{ print "echo `fgrep " $2 " /path/to/spamboxes.* \ > > >> > | wc -l` " $2 } ' | sort | uniq | tail +2 | sh | sort -rn > > >> > > >> $ ./spam-check > > >> ./spam-check: line 2: : command not found > > >> ./spam-check: line 3: : command not found > > >> ./spam-check: line 5: : command not found > > I just got back to working on these problems, and a fresh mind seems to have > solved 90% of my problems. They were all due to the leading spaces in each > line, remove them, and the script runs well with one caveat: > > grep: : No such file or directory > > I can only figure that is erroring in 2 places, at > /etc/mail/spamassassin/*.cf > which has 8 *.cf files in it. Or when looking for my spambox, which is > located at /home/robbo/.Mail/SpamPile/cur/. > > 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. hth, -- Bob