bash expansion help
Lennart Sorensen
lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Mon Feb 5 18:16:54 UTC 2007
On Mon, Feb 05, 2007 at 12:57:41PM -0500, Steve Harvey wrote:
> bash will happily do recursive brace expansion on it's input:
>
> $ #I'm using a pared down version for brevity
> $ echo GENERIC_ARM ARM{610,710,_{SA110,SA1100,XSCALE}}
> GENERIC_ARM ARM610 ARM710 ARM_SA110 ARM_SA1100 ARM_XSCALE
> $ # Presuming it's a variable within a script that we want to expand
> $ arm_opts="GENERIC_ARM ARM{610,710,_{SA110,SA1100,XSCALE}}"
> $ echo $arm_opts
> GENERIC_ARM ARM{610,710,_{SA110,SA1100,XSCALE}}
> $ # not what we want, therefore pipe it into bash
>
> Can you find a way do do this with less overhead? I count two
> invocations of the shell, one implicit by using `` and one explicit.
Hmm, I missed that if was expanding $arm_opts. I had been playing with
it as just foo=`echo ARM{610,710,_{SA110,SA1100,XSCALE}}` which didn't
need another shell. Given the extra variable, no I don't think I can
find a shorter method. Not sure eval or anything else would do it, but
it would take more characters to do it for sure.
--
Len Sorensen
--
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