3 ms·
Bash sucks at slicing arrays (always need a `[@]`): ${array[@]:$from:$to} Zsh is a bit nicer: ${array:$from:$to}
by luikore 13y ago
Bash sucks at slicing arrays (always need a `[@]`):
${array[@]:$from:$to}
Zsh is a bit nicer:
${array:$from:$to}
- kps 13y agoIn Bourne-descended shells, as an unfortunate historical accident, if FOO is an array, then referring to FOO without a subscript is equivalent to referring to its zeroth element. For your example, ${array:$from:$to} is equivalent to ${array[0]:$from:$to} And likewise $ FOO=(a b c d) $ FOO=x $ echo ${FOO} x $ echo ${FOO[@]} x b c d