in reply to String expansion script
This is great. I especially like the distinction between [01:20] and [1:20].
The zsh shell has a brace expansion function, so you can write this in zsh:
which printsecho f-{fred,barney,vilma}/h{08..22}.t
Zsh makes the distinction between {08..22} and {8..22}. Bash 3.0 has cloned this numeric brace expansion feature too (it had non-numeric brace expansion originally), but it expands {08..11} as 8 9 10 11. (Brace expansion with multiple braces sometimes expand in a different order in the shells and your program.)f-fred/h08.t f-fred/h09.t f-fred/h10.t f-fred/h11.t f-fred/h12.t f-fre +d/h13.t f-fred/h14.t f-fred/h15.t f-fred/h16.t f-fred/h17.t f-fred/h1 +8.t f-fred/h19.t f-fred/h20.t f-fred/h21.t f-fred/h22.t f-barney/h08. +t f-barney/h09.t f-barney/h10.t f-barney/h11.t f-barney/h12.t f-barne +y/h13.t f-barney/h14.t f-barney/h15.t f-barney/h16.t f-barney/h17.t f +-barney/h18.t f-barney/h19.t f-barney/h20.t f-barney/h21.t f-barney/h +22.t f-vilma/h08.t f-vilma/h09.t f-vilma/h10.t f-vilma/h11.t f-vilma/ +h12.t f-vilma/h13.t f-vilma/h14.t f-vilma/h15.t f-vilma/h16.t f-vilma +/h17.t f-vilma/h18.t f-vilma/h19.t f-vilma/h20.t f-vilma/h21.t f-vilm +a/h22.t
By the way, your program does not fully expand m[2:5]-{a:t:g:c}, it just prints the four strings m[2:5]-a m[2:5]-t m[2:5]-g m[2:5]-c. Is that intentional?
Also, your program does not seem to be able to expand braces embedded in each other, such as {/usr{:/local}:/var}/lib. Bash expands this to /usr/lib /usr/local/lib /var/lib.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: String expansion script
by jdporter (Paladin) on Feb 03, 2005 at 20:23 UTC | |
by ambrus (Abbot) on Feb 03, 2005 at 20:30 UTC | |
by jdporter (Paladin) on Feb 03, 2005 at 20:52 UTC |