bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: L A Walsh
Subject: find len of array w/name in another var...(bash 4.4.12)
Date: Tue, 20 Oct 2020 00:58:36 -0700
User-agent: Thunderbird

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 !name was supposed to take the place
of using $an, but haven't seen a case where !an works where
an points to an array name.

Is there a place in the bash manpage that gives an example of using !name
where name points to an array?

Thanks...
-l





reply via email to

[Prev in Thread] Current Thread [Next in Thread]