| Chris F.A. Johnson 2006-06-26, 1:22 pm |
| On 2006-06-26, kunjathi@gmail.com wrote:
> Hi
>
> I've below string.
>
> acl add name=FTP_1 audit=traffic auth_needed=no dest=ipaddr:Data1
> dest_burb=external authmethods='' source=ipaddr:Data2
>
> acl add name=FTP_2 varaiblestring=xxxxx dest=ipaddr:Dat1
> dest_burb=external authmethods='' variablestring=xxxx
> source=ipaddr:Data2
>
>
> How can I extract "dest=ipaddr:Data1" and "source=ipaddr:Data2" from
> this. The pattern before and after these string are varying. My purpose
> is to extract info based on the 'dest=' and "source=" string.
str="acl add name=FTP_2 varaiblestring=xxxxx dest=ipaddr:Dat1 dest_burb=external authmethods='' variablestring=xxxx source=ipaddr:Data2"
temp=${str%%dest=*}
temp=${str#"$temp"}
eval "${temp%% *}"
temp=${str%%source=*}
temp=${str#"$temp"}
eval "${temp%% *}"
echo "dest=$dest source=$source"
--
Chris F.A. Johnson, author <http://cfaj.freeshell.org>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
|