bash character substitution? Need help

Grant Cullen grant.cullen-rieW9WUcm8FFJ04o6PK0Fg at public.gmane.org
Sat Feb 7 01:01:00 UTC 2004


My fault bad typing, should be ${X:1:17}

Grant

-----Original Message-----
From: owner-tlug-lxSQFCZeNF4 at public.gmane.org [mailto:owner-tlug at ss.org]On Behalf Of Madison
Kelly
Sent: Friday, February 06, 2004 14:15
To: tlug-lxSQFCZeNF4 at public.gmane.org
Subject: Re: [TLUG]: bash character substitution? Need help


Quick note, I tried running the script (to see if I could decypher it)
and I got this;
./test-parse: line 3: ${X,1,17}: bad substitution

Madison

Grant Cullen wrote:
> Madison, the following will give the basic parsing.
>
> Good luck
>
> #!/bin/bash
> X='00:11:22:33:44:55>21,53,80-85'
> MAC=${X,1,17}
> [ ${#X} -gt 18 ] &&
>  {
>   # we have ports - length greater than 18
>   IFS=','
>   for PORT in ${x:18}
>    do
>     echo "iptable entry with port " $PORT
>    done
>  } ||
>  {
>   # no ports
>   echo "iptable entry without ports"
>  }
>
> Grant Cullen
> JADALL Consulting Ltd.
> grant.cullen-rieW9WUcm8FFJ04o6PK0Fg at public.gmane.org
> 416-706-4447

--
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


--
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