Re: find len of array w/name in another var...(bash 4.4.12)

2020-10-21 Thread Greg Wooledge
On Tue, Oct 20, 2020 at 04:57:36PM -0700, L A Walsh wrote: > > > On 2020/10/20 01:29, Andreas Kusalananda Kähäri wrote: > > > > In bash 4.3+, I would manke your "ar" variable a name reference variable > > instead: > > > > $ ar1=(1 2 3 44) > > $ declare -n ar=ar1 > > $ echo "${#ar[@]}" > > 4 > >

Re: find len of array w/name in another var...(bash 4.4.12)

2020-10-20 Thread L A Walsh
On 2020/10/20 01:29, Andreas Kusalananda Kähäri wrote: In bash 4.3+, I would manke your "ar" variable a name reference variable instead: $ ar1=(1 2 3 44) $ declare -n ar=ar1 $ echo "${#ar[@]}" 4 Ya, I was trying to use the 'byname' feature for older/wider support...sigh

Re: find len of array w/name in another var...(bash 4.4.12)

2020-10-20 Thread Martin Schulte
Hello! Am Tue, 20 Oct 2020 00:58:36 -0700 schrieb L A Walsh : > There's got to be an easier way to do this, but not remembering or finding > it: > > First tried the obvious: > declare -a ar1=([0]="1" [1]="2" [2]="3" [3]="44") > an=ar1 > echo ${#!an[@]} > -bash: ${#!an[@]}: bad substitution > > T

Re: find len of array w/name in another var...(bash 4.4.12)

2020-10-20 Thread Andreas Kusalananda Kähäri
On Tue, Oct 20, 2020 at 12:58:36AM -0700, L A Walsh wrote: > There's got to be an easier way to do this, but not remembering or finding > it: > > First tried the obvious: > declare -a ar1=([0]="1" [1]="2" [2]="3" [3]="44") > an=ar1 > echo ${#!an[@]} > -bash: ${#!an[@]}: bad substitution > > This

Re: find len of array w/name in another var...(bash 4.4.12)

2020-10-20 Thread Martin Schulte
Hello! Am Tue, 20 Oct 2020 00:58:36 -0700 schrieb L A Walsh : > There's got to be an easier way to do this, but not remembering or finding > it: > > First tried the obvious: > declare -a ar1=([0]="1" [1]="2" [2]="3" [3]="44") > an=ar1 > echo ${#!an[@]} > -bash: ${#!an[@]}: bad substitution > > T

find len of array w/name in another var...(bash 4.4.12)

2020-10-20 Thread L A Walsh
There's got to be an easier way to do this, but not remembering or finding it: First tried the obvious: declare -a ar1=([0]="1" [1]="2" [2]="3" [3]="44") an=ar1 echo ${#!an[@]} -bash: ${#!an[@]}: bad substitution This works but feels kludgy an=ar1 eval echo \${#$an[@]} 4 I thought the !na