Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 05-26-2009, 03:55 PM   #1
LQ Newbie
Registered: May 2009
Distribution: Fedora
Posts: 6

Rep: Reputation: 0
bash string matching


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.$$
# 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.$$
# Low score
mv /var/tempfs/out.$$ /home/spam_drop/`date +%Y-%m-%d_%R`-$$
$SENDMAIL "$@" < /var/tempfs/out.$$

In the line "if $EGREP -q "^X-Spam-Level: \*{$SPAMLIMIT,}" < /var/tempfs/out.$$".

Thanks in advance!
Old 05-26-2009, 06:50 PM   #2
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 336

Rep: Reputation: 141Reputation: 141
In the extended regular expressions used by egrep
matches n or more of the preceding item.

So if the variable $SPAMLIMIT contains an integer
will match a string of literal * at least $SPAMLIMIT long.

\*{4,} matches ***** but does not match ***
Old 05-26-2009, 07:27 PM   #3
LQ Newbie
Registered: May 2009
Distribution: Fedora
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks! I should have been looking for egrep syntax. I'm such a noob.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pattern matching in BASH. ccin1492 Programming 8 12-19-2008 12:00 PM
IPTables String Matching on FC5 jwhitehead Linux - Security 2 07-02-2006 01:42 AM
bash script pattern matching thedude2010 Programming 9 06-02-2006 03:39 AM
regular expresions: java: matching lines with out string zymos Programming 1 05-28-2005 10:17 AM
Pattern Matching Help in Bash script cmfarley19 Programming 1 04-07-2004 10:22 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:52 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration