bash expansion help
Christopher Friedt
cfriedt-u6hQ6WWl8Q3d1t4wvoaeXtBPR1lH4CV8 at public.gmane.org
Mon Feb 5 08:32:05 UTC 2007
Hi Paul,
I'm very familiar w/ sed, and I would gladly use it. However, I don't
know enough about sed to use these types of regular expressions w/ it. I
usually just attempt regexp stuff w/ range matching and whitespace.
In this particular case, I would have needed to use some extension that
had memory as well (for previous matches).
I think something along the line of
(1){a,b,c...} => 1a 1b 1c
where a b c could have any number of the same patterns, would have done
the trick... I'm not really sure how to code that w/ gnu or posix
regular expressions... Any suggestions? It's probably pretty straight
forward.
Luckily, the expansion that I needed was exactly the same type of
expansion used in bash for filenames. Except in this case, the items
didn't actually represent filenames. For some reason I couldn't make
bash do the proper expansion with ${}.
so Steven's suggestion of
echo echo $var | bash
was exactly the solution I was looking for.
I can't actually use perl in this case either, because my task is going
to need to be run w/ a bare minimum of dependencies, and especially disk
space. Bash for me was about as large as I wanted to get.
Thanks for the reply in any case though ;-)
Do you know the right way to key in the type of grep regexp mentioned
above? I'll give it another shot - it would tidy up my code a bit anyway.
~/Chris
Paul King wrote:
> [ Charset UTF-8 unsupported, converting... ]
>> Hi everyone,
>>
>> I'm trying to find some method to expand this variable $arm_opts:
>>
>> "GENERIC_ARM ARM{610,710,720T,920T,922T,926T,_{SA110,SA1100,XSCALE}}"
>>
>> to this:
>>
>> "GENERIC_ARM ARM610 ARM710 ARM720T ARM920T ARM922T ARM926T ARM_SA110
>> ARM_SA1100 ARM_XSCALE"
>
> Looks easy enough to parse in Perl. Any reason to insist on Bash?
>
> In BASH, I find it easier to parse through a list if you use space
> delimiters. I couldn't get it to work with my standard method. I
> suggest, if BASH is insisted upon and Perl must be avoided, that you use
> sed/awk (probably sed more than awk).
>
> In case you don't know (many seem to think sed is out of "fahsion"), sed
> is a parser, like perl (sed stands for Stream editor). THere are some
> similarities in syntax, but sed is not a language, like Perl is.
>
> Paul King
>
>> in bash.
>>
>> Any tips ?
>>
>>
>> Thanks,
>>
>> ~/Chris
>> --
>> The Toronto Linux Users Group. Meetings: http://gtalug.org/
>> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
>> How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
>>
> --
> The Toronto Linux Users Group. Meetings: http://gtalug.org/
> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
>
>
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list