Posix string to match [[0-999]]


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Posix string to match [[0-999]]
# 1  
Old 10-14-2005
Question Posix string to match [[0-999]]

Hi, I would like to set up a Posix string to match the subject line in spam e-mails which contain
"[" followed by a number, followed by "]"

How do I get the square brackets recognised as literals and then include them in a string so that I can reject spam with things like [14] in the subject line.

Last edited by Mair55; 10-14-2005 at 07:08 PM..
# 2  
Old 10-14-2005
Excuse my sarcasm, I'm wrestling with a ksh script and the mmmmmmmms struck my me funny.
Have you tried something like "\[[0-9][0-9][0-9]\]"
# 3  
Old 10-14-2005
Not sure what a posix string means. But for a regular expression for grep or something is easy...

grep "\[[0-9]*\]"
# 4  
Old 10-14-2005
No problem

All excused - good luck with script Smilie

Last edited by Mair55; 10-14-2005 at 07:21 PM..
# 5  
Old 10-14-2005
Thanks very much

I will try both suggestions - am new to regular expressions
Smilie
# 6  
Old 10-14-2005
Quote:
Originally Posted by Perderabo
Not sure what a posix string means. But for a regular expression for grep or something is easy...

grep "\[[0-9]*\]"
There is one case where this will not work the way you wish, but I leave that to you to discover when you examine the syntax of what Perderabo posted.
# 7  
Old 10-15-2005
one case...

Do you mean it will match [] as well as all the patterns with numbers in square brackets. If so I don't think this will be a problem - you would need to be pretty odd to include [] in the subject box of a non-spam e-mail. If this isn't the case you mean, please take pity and tell me - as i said I am new to posix and can do with all the help I can get. Thanks
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match exactly a string

I am formatting my code and for that I am trying to write a script which can quicken some repetitive work. I need to match "==" exactly in a string and replace it by inserting a (single) blank space before and after it. Sample Strings: 1.this.something =='something'.that... (9 Replies)
Discussion started by: prohank
9 Replies

2. Shell Programming and Scripting

Print ALL lines except if field is 999

Hi All!!! :-) I need a command that will print each line of a text file UNLESS the 3rd field of that line is equal to the number 999. (space seperated fields) Solaris10/BASH SHELL: INPUT.TXT aaa bbb 111 222 ccc ddd 333 444 eee fff 999 555 ggg hhh 666 777 aaa bbb 999 222 ccc ddd 333... (7 Replies)
Discussion started by: ajp7701
7 Replies

3. Shell Programming and Scripting

awk : match the string and string with the quotes :

Hi all, Here is the data file: - want to match only lan3 in the output . - not lan3:1 file : OPERATING_SYSTEM=HP-UX LOOPBACK_ADDRESS=127.0.0.1 INTERFACE_NAME="lan3" IP_ADDRESS="10.53.52.241" SUBNET_MASK="255.255.255.192" BROADCAST_ADDRESS="" INTERFACE_STATE=""... (2 Replies)
Discussion started by: rveri
2 Replies

4. Shell Programming and Scripting

Match all except string(s) in posix extended

How to say "match anything but this or that string" using only posix extended syntax? I am not talking about egrep -v, I want this done entirely by the regular expression. Thanks (7 Replies)
Discussion started by: stevensw
7 Replies

5. Shell Programming and Scripting

Generate numbers 000 to 999

I have tried to make this script to generate: 000 001 002 ... 997 998 999 i=0 while do if then echo "00"$i else if && then echo "0"$i (5 Replies)
Discussion started by: locoroco
5 Replies

6. Shell Programming and Scripting

exact string match ; search and print match

I am trying to match a pattern exactly in a shell script. I have tried two methods awk '/\<mpath${CURR_MP}\>/{print $1 $2}' multipath perl -ne '/\bmpath${CURR_MP}\b/ and print' /var/tmp/multipath Both these methods require that I use the escape character. I am guessing that is why... (8 Replies)
Discussion started by: bash_in_my_head
8 Replies

7. Shell Programming and Scripting

Perl: Better way to match string within a string

Hi, I'm trying to get one field out of many as follows: A string of multiple fields separated with "/" characters: "/ab=12/cd=34/12=ab/34=cd/ef=pick-this.one/gh=blah/ij=something/" I want to pick up the field "ef=pick-this.one" which has no regular pattern except it starts with "ef=xxxx"... (3 Replies)
Discussion started by: Juha
3 Replies
Login or Register to Ask a Question