bash string matching
Hi,
I've recently added a new mail filter (bash script) to my server. Now I know this sort of thing should be taboo but I just copied and pasted the script not really understanding what it does or at least the language (bash) its written in. I've done some searching on the net to further my understanding of bash and have learned quite a bit. However, I don't understand what this comma is for: # Are there more than $SPAMLIMIT stars in X-Spam-Level header? : if $EGREP -q "^X-Spam-Level: \*{$SPAMLIMIT,}" < /var/tempfs/out.$$ then # Option 1: Move high scoring messages to sideline dir so # a human can look at them later: # mv out.$$ $SIDELINE_DIR/`date +%Y-%m-%d_%R`-$$ # mv /var/tempfs/out.$$ /home/spam_drop/`date +%Y-%m-%d_%R`-$$ # Option 2: Divert to an alternate e-mail address: # $SENDMAIL spamguy@localhost < /var/tempfs/out.$$ # Option 3: Delete the message rm -f /var/tempfs/out.$$ elif $EGREP -q "^X-Spam-Level: \*{$SPAMLOW,}" < /var/tempfs/out.$$ then # Low score mv /var/tempfs/out.$$ /home/spam_drop/`date +%Y-%m-%d_%R`-$$ else $SENDMAIL "$@" < /var/tempfs/out.$$ fi ... In the line "if $EGREP -q "^X-Spam-Level: \*{$SPAMLIMIT,}" < /var/tempfs/out.$$". Thanks in advance! |
In the extended regular expressions used by egrep
{n,} matches n or more of the preceding item. So if the variable $SPAMLIMIT contains an integer \*{$SPAMLIMIT,} will match a string of literal * at least $SPAMLIMIT long. e.g. \*{4,} matches ***** but does not match *** http://linux.die.net/man/1/egrep |
Thanks! I should have been looking for egrep syntax. I'm such a noob.
|
All times are GMT -5. The time now is 10:50 AM. |