bash character substitution? Need help

Madison Kelly linux-5ZoueyuiTZhBDgjK7y7TUQ at public.gmane.org
Fri Feb 6 17:40:08 UTC 2004


Hi all,

   I am working on an iptables bash script but am handicapped by not 
being a programmer (or, just barely being one). Anyway, I've been able 
to figure out how to take a string and read out variables based on a 
character to split on but now what I need it to read a value into the 
same variable over and over again based on the split. Here is my 
specific issue:

I have the variable:

# Enter as (MAC address)>Port(-range),Port(-range),..,Port(-range)
TRUSTED_IB_TCP=00:11:22:33:44:55>21,53,80-85

   Now I want to check and see if ports are defined. If not, allow all 
ports from the given MAC address. If so, read out the ports one after 
another in a 'for/while' style loop splitting on the ','. Then inside 
each of those, split on '-' and check to see if there is a value after 
the '-'.

   The problem is, I know how to split on the ',' (IFS=',' ...) but this 
doesn't seem like it is going to help me because I want to run a 
'for/while' loop for each value, not assign new variables based on the 
split (like I have done so far). Is there some way to substitute the ',' 
with ' ' and then do a 'for/while' loop?

   I am Googling now but I am having trouble finding the answer. I am 
hoping someone here might be able to point me in the right direction. 
Thanks!

Madison

PS - If it will help, I'll post what I have of the relevant parts of the 
script.

--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list