Am 28.04.2012 05:05, schrieb Linda Walsh:
Maarten Billemont wrote:
On 26 Apr 2012, at 06:30, John Kearney wrote:
Am 26.04.2012 06:26, schrieb Linda Walsh:
I know I can get
a="abcdef" echo "${a[2:4]}" = cde
how do I do:
typeset -a a=(apple berry cherry date); then get:
echo ${a[1:2]} = "berry" "cherry" ( non-grouped args)
I tried to do it in a function and hurt myself.
echo ${a[@]:1:2}
I see little reason to ask bash to wordsplit the elements after
expanding them.
You ought to quote that expansion.
---
Good point.
Since if you do:
> a=( 'apple pie' 'berry pie' 'cherry cake' 'dates divine')
> b=( ${a[@]:1:2} )
> echo ${#b[*]}
4
#yikes!
> b=( "${a[@]:1:2}" )
2
#woo!
I'd guess the original poster probably figured, I'd figure out the
correct
form pretty quickly in usage. but thanks for your insight.
( (to all)....*sigh*)
I "always" quote not sure why I didn't that time.
Except that it was just a quick response to a simple question.
but of course your right.